Skip to content

Commit 5f85c5a

Browse files
authored
Merge pull request #63 from Caliburn-Micro/vb2ae-patch-3
Update dotnet-maui.md
2 parents 3e117e4 + f107387 commit 5f85c5a

File tree

1 file changed

+80
-75
lines changed

1 file changed

+80
-75
lines changed

documentation/dotnet-maui.md

Lines changed: 80 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,58 @@ or if you have an older version
1414

1515
Add a Caliburn.Micro.Maui nuget package to your solution. From the terminal window you can use this command
1616

17-
dotnet add package Caliburn.Micro.Maui --version 5.0.183-beta --source "https://nuget.pkg.github.com/caliburn-micro/index.json"
17+
dotnet add package Caliburn.Micro.Maui --version 5.0.183-beta --source "https://nuget.pkg.github.com/caliburn-micro/index.json"
1818

1919
In the platforms folder android modify the MainApplication class to this
2020

21-
[Application]
22-
public class MainApplication : Caliburn.Micro.Maui.CaliburnApplication
23-
{
24-
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
25-
: base(handle, ownership)
26-
{
27-
Initialize();
28-
}
29-
30-
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
31-
32-
protected override void Configure()
33-
{
34-
base.Configure();
35-
}
36-
37-
protected override IEnumerable<Assembly> SelectAssemblies()
38-
{
39-
return new List<Assembly>() { typeof(App).Assembly };
40-
}
41-
}
21+
[Application]
22+
public class MainApplication : Caliburn.Micro.Maui.CaliburnApplication
23+
{
24+
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
25+
: base(handle, ownership)
26+
{
27+
Initialize();
28+
}
29+
30+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
31+
32+
protected override void Configure()
33+
{
34+
base.Configure();
35+
}
36+
37+
protected override IEnumerable<Assembly> SelectAssemblies()
38+
{
39+
return new List<Assembly>() { typeof(App).Assembly };
40+
}
41+
}
42+
4243
In the iOS folder modify AppDelgate to this
4344

44-
[Register("AppDelegate")]
45-
public class AppDelegate : Caliburn.Micro.Maui.CaliburnApplicationDelegate
46-
{
47-
public AppDelegate()
45+
[Register("AppDelegate")]
46+
public class AppDelegate : Caliburn.Micro.Maui.CaliburnApplicationDelegate
4847
{
49-
Initialize();
50-
}
48+
public AppDelegate()
49+
{
50+
Initialize();
51+
}
5152

52-
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
53-
}
53+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
54+
}
55+
5456
In the MacCatalyst folder modify AppDelegate to this
5557

56-
[Register("AppDelegate")]
57-
public class AppDelegate : Caliburn.Micro.Maui.CaliburnApplicationDelegate
58-
{
59-
public AppDelegate()
60-
{
61-
Initialize();
62-
}
58+
[Register("AppDelegate")]
59+
public class AppDelegate : Caliburn.Micro.Maui.CaliburnApplicationDelegate
60+
{
61+
public AppDelegate()
62+
{
63+
Initialize();
64+
}
6365

64-
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
65-
}
66+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
67+
}
68+
6669
In the Windows folder modify the App.Xaml to this
6770

6871
<cal:CaliburnApplication
@@ -78,49 +81,51 @@ Make sure you replace x:Class with your apps name
7881

7982
cs file
8083

81-
public partial class App : Caliburn.Micro.Maui.CaliburnApplication
82-
{
83-
/// <summary>
84-
/// Initializes the singleton application object. This is the first line of authored code
85-
/// executed, and as such is the logical equivalent of main() or WinMain().
86-
/// </summary>
87-
public App()
88-
{
89-
this.InitializeComponent();
90-
Initialize();
91-
}
92-
93-
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
94-
}
84+
public partial class App : Caliburn.Micro.Maui.CaliburnApplication
85+
{
86+
/// <summary>
87+
/// Initializes the singleton application object. This is the first line of authored code
88+
/// executed, and as such is the logical equivalent of main() or WinMain().
89+
/// </summary>
90+
public App()
91+
{
92+
this.InitializeComponent();
93+
Initialize();
94+
}
95+
96+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
97+
98+
9599
The App.Xaml in project root folder should be modified like this
96100

97-
<?xml version = "1.0" encoding = "UTF-8" ?>
98-
<cal:MauiApplication xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
99-
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
100-
xmlns:local="clr-namespace:MauiApp2"
101-
xmlns:cal="using:Caliburn.Micro.Maui"
102-
x:Class="MauiApp2.App">
103-
<Application.Resources>
104-
<ResourceDictionary>
105-
<ResourceDictionary.MergedDictionaries>
106-
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
107-
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
108-
</ResourceDictionary.MergedDictionaries>
109-
</ResourceDictionary>
110-
</Application.Resources>
111-
</cal:MauiApplication>
101+
<?xml version = "1.0" encoding = "UTF-8" ?>
102+
<cal:MauiApplication xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
103+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
104+
xmlns:local="clr-namespace:MauiApp2"
105+
xmlns:cal="using:Caliburn.Micro.Maui"
106+
x:Class="MauiApp2.App">
107+
<Application.Resources>
108+
<ResourceDictionary>
109+
<ResourceDictionary.MergedDictionaries>
110+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
111+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
112+
</ResourceDictionary.MergedDictionaries>
113+
</ResourceDictionary>
114+
</Application.Resources>
115+
</cal:MauiApplication>
116+
112117
Replace xmlns:Local with your app name
113118

114119
The App.Xamal.cs file
115120

116-
public partial class App : Caliburn.Micro.Maui.MauiApplication
117-
{
118-
public App()
121+
public partial class App : Caliburn.Micro.Maui.MauiApplication
119122
{
120-
InitializeComponent();
123+
public App()
124+
{
125+
InitializeComponent();
121126

122-
Initialize();
127+
Initialize();
123128

124-
DisplayRootViewForAsync<MainViewModel>();
129+
DisplayRootViewForAsync<MainViewModel>();
130+
}
125131
}
126-
}

0 commit comments

Comments
 (0)