Skip to content

Commit c1f65f5

Browse files
authored
Merge pull request #94 from egvijayanand/working
Native WinUI 3 Blazor Hybrid Sample
2 parents b13ba52 + 216ea41 commit c1f65f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2302
-22
lines changed

README.md

+21-22
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,30 @@ Join me on [**Developer Thoughts**](https://egvijayanand.in/), an exclusive blog
66

77
_Note: Samples are in the process of migrating to the latest framework version, so there would be a change in the directory structure. Kindly bear with this._
88

9+
### .NET MAUI 8 Samples
10+
911
Made available in the `src\NET_8\` directory:
10-
* `EmbeddedWindows` - .NET MAUI Page embedded in a Native WinUI 3 App, targeting .NET 8 (`net8.0-windows10.0.19041.0`)
11-
- Refer to this [article](https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/) for working with this sample
12-
* `MapsApp` - .NET MAUI Maps embedded in a Native WinUI 3 App, targeting .NET 8 (`net8.0-windows10.0.19041.0`)
13-
- Refer to this [article](https://egvijayanand.in/2024/03/07/dotnet-maui-community-toolkit-maps-in-winui-3-app/) for working with this sample
14-
* `ThemedApp` - Sample app for .NET MAUI App Theming
15-
- Refer to this [article](https://egvijayanand.in/2024/07/03/dotnet-maui-developer-tips-app-theming/) for further details
16-
* `DateCalculator`
17-
- MVVM Sample
18-
- Xamarin Forms and .NET MAUI in a single solution
19-
- WPF and WinUI projects to illustrate the reuse of ViewModels across UI frameworks
20-
- WinForms project to illustrate the reuse of ViewModels across non-XAML UI framework too
21-
- Shared business logic as a separate library project
22-
- ViewModels implemented with [CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm) NuGet package
23-
* `UnifiedDateCalculator`
24-
- Shared class library sample
25-
- UI, ViewModel, Model, and Business logic all from shared project
26-
- Head projects serve as an app container
27-
- Both Xamarin.Forms and .NET MAUI from a single project - `DateCalculator.UI`
12+
13+
|Solution Title|Description|
14+
|:---:|:---|
15+
|`EmbeddedWindows`|.NET MAUI Page embedded in a Native WinUI 3 App <br /> Refer to this [.NET MAUI - Native Embedding](https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/) article for working with this sample|
16+
|`MapsApp`|.NET MAUI Maps embedded in a Native WinUI 3 App <br /> Refer to this [.NET MAUI Community Toolkit Maps in WinUI 3 App](https://egvijayanand.in/2024/03/07/dotnet-maui-community-toolkit-maps-in-winui-3-app/) article for working with this sample|
17+
|`ThemedApp`|Sample app for .NET MAUI App Theming <br /> Refer to this [.NET MAUI - App Theming](https://egvijayanand.in/2024/07/03/dotnet-maui-developer-tips-app-theming/) article for further details|
18+
|`DateCalculator`|<ul><li>MVVM Sample</li><li>Xamarin Forms and .NET MAUI in a single solution</li><li>WPF and WinUI projects to illustrate the reuse of ViewModels across UI frameworks</li><li>WinForms project to illustrate the reuse of ViewModels across non-XAML UI framework too</li><li>Shared business logic as a separate library project</li><li>ViewModels implemented with [CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm) (aka Microsoft MVVM Toolkit) NuGet package</li></ul>|
19+
|`UnifiedDateCalculator`|<ul><li>Shared class library sample</li><li>UI, ViewModel, Model, and Business logic all from shared project</li><li>Head projects serve as an app container</li><li>Both Xamarin.Forms and .NET MAUI UI definition from a single project - `DateCalculator.UI`</li><li>ViewModels implemented with [CommunityToolkit.Mvvm](https://www.nuget.org/packages/CommunityToolkit.Mvvm) (aka Microsoft MVVM Toolkit) NuGet package</li></ul>|
20+
21+
### .NET MAUI 9 Samples
2822

2923
Made available in the `src\NET_9\` directory:
3024

3125
|Solution Title|Description|
3226
|:---:|:---|
33-
|`EmbeddedAndroid`|.NET MAUI Page embedded in a .NET 9 for Android App, targeting .NET 9 <br /> Refer to this [article](https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/) for working with this sample|
34-
|`EmbeddediOS`|.NET MAUI Page embedded in a .NET 9 for iOS App, targeting .NET 9 <br /> Refer to this [article](https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/) for working with this sample|
35-
|`EmbeddedWindows`|.NET MAUI Page embedded in a Native WinUI 3 App, targeting .NET 9 <br /> Refer to this [article](https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/) for working with this sample|
36-
|`MapsApp`|Using .NET MAUI [CommunityToolkit.Maui.Maps](https://www.nuget.org/packages/CommunityToolkit.Maui.Maps) embedded in a Native WinUI 3 App, targeting .NET 9 <br /> Refer to this [article](https://egvijayanand.in/2024/03/07/dotnet-maui-community-toolkit-maps-in-winui-3-app/) for working with this sample|
27+
|`EmbeddedAndroid`|.NET MAUI Page embedded in a .NET 9 for Android App <br /> Refer to this [.NET MAUI - Native Embedding](https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/) article for working with this sample|
28+
|`EmbeddediOS`|.NET MAUI Page embedded in a .NET 9 for iOS App <br /> Refer to this [.NET MAUI - Native Embedding](https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/) article for working with this sample|
29+
|`EmbeddedWindows`|.NET MAUI Page embedded in a Native WinUI 3 App <br /> Refer to this [.NET MAUI - Native Embedding](https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/) article for working with this sample|
30+
|`MapsApp`|Using .NET MAUI [CommunityToolkit.Maui.Maps](https://www.nuget.org/packages/CommunityToolkit.Maui.Maps) embedded in a Native WinUI 3 App <br /> Refer to this [.NET MAUI Community Toolkit Maps in WinUI 3 App](https://egvijayanand.in/2024/03/07/dotnet-maui-community-toolkit-maps-in-winui-3-app/) article for working with this sample|
3731
|`HybridWebViewApp`|A sample .NET MAUI App showcasing the features of the new [HybridWebView](https://learn.microsoft.com/en-us/dotnet/maui/whats-new/dotnet-9?view=net-maui-9.0#hybridwebview) control.|
32+
|`WinUIBlazor`|.NET MAUI `BlazorWebView` embedded in a Native WinUI 3 App, making it as a Blazor Hybrid app <br /> Refer to this [.NET MAUI - Blazor Hybrid - WinUI 3](https://egvijayanand.in/2023/03/29/dotnet-maui-blazor-hybrid-winui-3/) article for working with this sample|
3833

3934
Made available in the the `src\` directory:
4035

@@ -63,6 +58,8 @@ Made available in the the `src\` directory:
6358
**Error message:**
6459
Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
6560

61+
### .NET MAUI UI Challenge - C# Version
62+
6663
* C# Samples - C# version of the [.NET MAUI UI Challenge](https://aka.ms/maui/UIChallenge) - [Awesome UIs](https://github.com/jsuarezruiz/dotnet-maui-showcase) without any XAML usage - Stay tuned for more samples ...
6764
- Made available under the [C#-Samples](/src/C%23-Samples/) folder
6865
- Design credit to their respective owners
@@ -87,6 +84,8 @@ Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies: The speci
8784
- [MAUI Pets](https://github.com/BryanOroxon/MAUIPETS)
8885
- [SpaceX History](https://github.com/EduardoReisDev/SpaceXhistory)
8986

87+
### .NET MAUI - F# Samples
88+
9089
* F# Samples
9190
- Made available under the [F#-Samples](/src/F%23-Samples/) folder developed with Fabulous
9291
- FSApp - A F# sample app (with DI option)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
global using WinUIBlazor;
2+
global using WinUIBlazor.Views;
3+
4+
// Static
5+
global using static Microsoft.Maui.Graphics.Colors;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Router AppAssembly="@GetType().Assembly" AdditionalAssemblies="[ typeof(Counter).Assembly ]">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
</Found>
5+
<NotFound>
6+
<LayoutView Layout="@typeof(MainLayout)">
7+
<p>Sorry, there's nothing at this address.</p>
8+
</LayoutView>
9+
</NotFound>
10+
</Router>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Application
3+
x:Class="WinUIBlazor.MyApp"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design"
7+
xmlns:local="clr-namespace:WinUIBlazor"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
mc:Ignorable="d">
10+
<Application.Resources>
11+
<ResourceDictionary>
12+
<ResourceDictionary.MergedDictionaries>
13+
<ResourceDictionary Source="Resources/Colors.xaml" />
14+
<ResourceDictionary Source="Resources/Styles.xaml" />
15+
</ResourceDictionary.MergedDictionaries>
16+
<!-- Additional Styles -->
17+
<x:Double x:Key="ItemSpacing">10</x:Double>
18+
19+
<Style
20+
ApplyToDerivedTypes="True"
21+
TargetType="StackBase">
22+
<Setter Property="Spacing" Value="{StaticResource ItemSpacing}" />
23+
</Style>
24+
25+
<Style
26+
x:Key="MauiLabel"
27+
TargetType="Label">
28+
<Setter Property="TextColor" Value="{AppThemeBinding Dark={StaticResource White}, Light={StaticResource Primary}}" />
29+
</Style>
30+
31+
<Style
32+
x:Key="Action"
33+
TargetType="Button">
34+
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark={StaticResource BackgroundDark}, Light={StaticResource BackgroundLight}}" />
35+
<Setter Property="TextColor" Value="{AppThemeBinding Dark={StaticResource TextDark}, Light={StaticResource TextLight}}" />
36+
<Setter Property="FontFamily" Value="{StaticResource AppFont}" />
37+
<Setter Property="FontSize" Value="{StaticResource AppFontSize}" />
38+
<Setter Property="Padding" Value="14,10" />
39+
</Style>
40+
41+
<Style
42+
x:Key="PrimaryAction"
43+
BasedOn="{StaticResource Action}"
44+
TargetType="Button">
45+
<Setter Property="BackgroundColor" Value="{StaticResource Primary}" />
46+
<Setter Property="FontAttributes" Value="Bold" />
47+
<Setter Property="TextColor" Value="{StaticResource White}" />
48+
</Style>
49+
</ResourceDictionary>
50+
</Application.Resources>
51+
</Application>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace WinUIBlazor
2+
{
3+
public partial class MyApp : Application
4+
{
5+
public MyApp()
6+
{
7+
InitializeComponent();
8+
UserAppTheme = PlatformAppTheme;
9+
}
10+
11+
protected override Window CreateWindow(IActivationState? activationState)
12+
=> new Window(new MainPage()) { Title = "WinUIBlazor" };
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<?xaml-comp compile="true" ?>
3+
<ResourceDictionary
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:local="clr-namespace:WinUIBlazor"
9+
mc:Ignorable="d">
10+
11+
<Color x:Key="Primary">#512BD4</Color>
12+
<Color x:Key="Secondary">#DFD8F7</Color>
13+
<Color x:Key="Tertiary">#2B0B98</Color>
14+
<Color x:Key="White">White</Color>
15+
<Color x:Key="Black">Black</Color>
16+
<Color x:Key="Gray100">#E1E1E1</Color>
17+
<Color x:Key="Gray200">#C8C8C8</Color>
18+
<Color x:Key="Gray300">#ACACAC</Color>
19+
<Color x:Key="Gray400">#919191</Color>
20+
<Color x:Key="Gray500">#6E6E6E</Color>
21+
<Color x:Key="Gray600">#404040</Color>
22+
<Color x:Key="Gray900">#212121</Color>
23+
<Color x:Key="Gray950">#141414</Color>
24+
25+
<Color x:Key="Light">#DFD8F7</Color>
26+
<Color x:Key="Dark">#2B0B98</Color>
27+
<Color x:Key="LightGray">#E5E5E1</Color>
28+
<Color x:Key="MidGray">#969696</Color>
29+
<Color x:Key="DarkGray">#505050</Color>
30+
31+
<SolidColorBrush x:Key="PrimaryBrush" Color="{StaticResource Primary}"/>
32+
<SolidColorBrush x:Key="SecondaryBrush" Color="{StaticResource Secondary}"/>
33+
<SolidColorBrush x:Key="TertiaryBrush" Color="{StaticResource Tertiary}"/>
34+
<SolidColorBrush x:Key="WhiteBrush" Color="{StaticResource White}"/>
35+
<SolidColorBrush x:Key="BlackBrush" Color="{StaticResource Black}"/>
36+
<SolidColorBrush x:Key="Gray100Brush" Color="{StaticResource Gray100}"/>
37+
<SolidColorBrush x:Key="Gray200Brush" Color="{StaticResource Gray200}"/>
38+
<SolidColorBrush x:Key="Gray300Brush" Color="{StaticResource Gray300}"/>
39+
<SolidColorBrush x:Key="Gray400Brush" Color="{StaticResource Gray400}"/>
40+
<SolidColorBrush x:Key="Gray500Brush" Color="{StaticResource Gray500}"/>
41+
<SolidColorBrush x:Key="Gray600Brush" Color="{StaticResource Gray600}"/>
42+
<SolidColorBrush x:Key="Gray900Brush" Color="{StaticResource Gray900}"/>
43+
<SolidColorBrush x:Key="Gray950Brush" Color="{StaticResource Gray950}"/>
44+
45+
<SolidColorBrush x:Key="LightBrush" Color="{StaticResource Light}" />
46+
<SolidColorBrush x:Key="DarkBrush" Color="{StaticResource Dark}" />
47+
<SolidColorBrush x:Key="LightGrayBrush" Color="{StaticResource LightGray}" />
48+
<SolidColorBrush x:Key="MidGrayBrush" Color="{StaticResource MidGray}" />
49+
<SolidColorBrush x:Key="DarkGrayBrush" Color="{StaticResource DarkGray}" />
50+
51+
<!-- Dark and Light App Theme -->
52+
<Color x:Key="BackgroundDark">#121212</Color>
53+
<Color x:Key="BackgroundLight">White</Color>
54+
<Color x:Key="TextDark">White</Color>
55+
<Color x:Key="TextLight">Black</Color>
56+
57+
<Color x:Key="Yellow100Accent">#F7B548</Color>
58+
<Color x:Key="Yellow200Accent">#FFD590</Color>
59+
<Color x:Key="Yellow300Accent">#FFE5B9</Color>
60+
<Color x:Key="Cyan100Accent">#28C2D1</Color>
61+
<Color x:Key="Cyan200Accent">#7BDDEF</Color>
62+
<Color x:Key="Cyan300Accent">#C3F2F4</Color>
63+
<Color x:Key="Blue100Accent">#3E8EED</Color>
64+
<Color x:Key="Blue200Accent">#72ACF1</Color>
65+
<Color x:Key="Blue300Accent">#A7CBF6</Color>
66+
67+
</ResourceDictionary>

0 commit comments

Comments
 (0)