Skip to content

Commit edf622c

Browse files
authored
Merge pull request #17 from egvijayanand/working
Samples updated to Preview 13 - #16
2 parents c7c1f1c + 407a085 commit edf622c

24 files changed

+401
-347
lines changed

src/MauiBlazorApp/MauiBlazorApp/App.xaml

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
23
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
3-
xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls"
44
xmlns:local="clr-namespace:MauiBlazorApp"
5-
x:Class="MauiBlazorApp.App"
6-
windows:Application.ImageDirectory="Assets">
5+
x:Class="MauiBlazorApp.App">
76
<Application.Resources>
87
<ResourceDictionary>
98

9+
<x:Double x:Key="ItemSpacing">10</x:Double>
10+
1011
<Color x:Key="PrimaryColor">#512BDF</Color>
1112
<Color x:Key="SecondaryColor">White</Color>
1213

14+
<Style TargetType="StackBase"
15+
ApplyToDerivedTypes="True">
16+
<Setter Property="Spacing"
17+
Value="{StaticResource ItemSpacing}" />
18+
</Style>
19+
1320
<Style TargetType="Label"
1421
ApplyToDerivedTypes="True">
1522
<Setter Property="TextColor"

src/MauiBlazorApp/MauiBlazorApp/App.xaml.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using BlazorApp.Services;
2-
using Application = Microsoft.Maui.Controls.Application;
32

43
namespace MauiBlazorApp
54
{

src/MauiBlazorApp/MauiBlazorApp/BlazorPage.designer.cs

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MauiBlazorApp/MauiBlazorApp/Controls/HStack.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
{
33
public class HStack : HorizontalStackLayout
44
{
5-
public HStack(double spacing = 0)
5+
public HStack()
6+
{
7+
8+
}
9+
10+
public HStack(double spacing)
611
{
712
Spacing = spacing;
813
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace MauiBlazorApp.Extensions
2+
{
3+
public static class SemanticExtensions
4+
{
5+
public static TBindable SemanticDesc<TBindable>(this TBindable bindable, string description)
6+
where TBindable : BindableObject
7+
{
8+
SemanticProperties.SetDescription(bindable, description);
9+
return bindable;
10+
}
11+
12+
public static TBindable SemanticHeading<TBindable>(this TBindable bindable, SemanticHeadingLevel headingLevel)
13+
where TBindable : BindableObject
14+
{
15+
SemanticProperties.SetHeadingLevel(bindable, headingLevel);
16+
return bindable;
17+
}
18+
19+
public static TBindable SemanticHint<TBindable>(this TBindable bindable, string hint)
20+
where TBindable : BindableObject
21+
{
22+
SemanticProperties.SetHint(bindable, hint);
23+
return bindable;
24+
}
25+
}
26+
}

src/MauiBlazorApp/MauiBlazorApp/MainPage.cs

+34-73
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace MauiBlazorApp
1+
using MauiBlazorApp.Extensions;
2+
3+
namespace MauiBlazorApp
24
{
35
public partial class MainPage : ContentPage
46
{
@@ -12,80 +14,39 @@ public MainPage()
1214

1315
private void InitializeComponent()
1416
{
15-
SetDynamicResource(BackgroundColorProperty, "SecondaryColor");
16-
var grid1 = new Grid()
17-
{
18-
RowSpacing = 25,
19-
Padding = Device.RuntimePlatform switch
20-
{
21-
Device.iOS => new Thickness(30, 60, 30, 30),
22-
_ => new Thickness(30),
23-
},
24-
RowDefinitions = Rows.Define(Auto, Auto, Auto, Auto, Star)
25-
};
26-
27-
var label1 = new Label()
28-
{
29-
Text = "Hello, World!",
30-
FontSize = 32,
31-
HorizontalOptions = LayoutOptions.Center
32-
};
33-
34-
GridLayout.SetRow(label1, 0);
35-
SemanticProperties.SetHeadingLevel(label1, SemanticHeadingLevel.Level1);
36-
37-
var label2 = new Label()
38-
{
39-
Text = "Welcome to .NET Multi-platform App UI",
40-
FontSize = 16,
41-
HorizontalOptions = LayoutOptions.Center
42-
};
43-
44-
GridLayout.SetRow(label2, 1);
45-
SemanticProperties.SetHeadingLevel(label2, SemanticHeadingLevel.Level1);
46-
SemanticProperties.SetDescription(label2, "Welcome to dot net Multi platform App U I");
47-
48-
counter = new Label()
49-
{
50-
Text = "Current count: 0",
51-
FontSize = 18,
52-
FontAttributes = FontAttributes.Bold,
53-
HorizontalOptions = LayoutOptions.Center
54-
};
55-
56-
GridLayout.SetRow(counter, 2);
57-
58-
var button1 = new Button()
59-
{
60-
Text = "Click me",
61-
FontAttributes = FontAttributes.Bold,
62-
HorizontalOptions = LayoutOptions.Center
63-
};
64-
65-
button1.Clicked += OnCounterClicked;
66-
GridLayout.SetRow(button1, 3);
67-
SemanticProperties.SetHint(button1, "Counts the number of times you click");
68-
69-
var image1 = new Image()
70-
{
71-
Source = "dotnet_bot.png",
72-
HorizontalOptions = LayoutOptions.Center,
73-
WidthRequest = 250,
74-
HeightRequest = 310
75-
};
76-
77-
GridLayout.SetRow(image1, 4);
78-
SemanticProperties.SetDescription(image1, "Cute dotnet bot waving hi to you!");
79-
80-
grid1.Add(label1);
81-
grid1.Add(label2);
82-
grid1.Add(counter);
83-
grid1.Add(button1);
84-
grid1.Add(image1);
85-
8617
Content = new ScrollView()
8718
{
88-
Content = grid1
19+
Content = new Grid()
20+
{
21+
RowSpacing = 25,
22+
RowDefinitions = Rows.Define(Auto, Auto, Auto, Auto, Star),
23+
Children =
24+
{
25+
new Label() { Text = "Hello, World!" }.Row(0)
26+
.FontSize(32)
27+
.CenterHorizontal()
28+
.SemanticHeading(SemanticHeadingLevel.Level1),
29+
new Label() { Text = "Welcome to .NET Multi-platform App UI" }.Row(1)
30+
.FontSize(18)
31+
.CenterHorizontal()
32+
.SemanticHeading(SemanticHeadingLevel.Level1)
33+
.SemanticDesc("Welcome to dot net Multi platform App U I"),
34+
new Label() { Text = "Current count: 0" }.Row(2)
35+
.Bold()
36+
.FontSize(18)
37+
.CenterHorizontal()
38+
.Assign(out counter),
39+
new Button() { Text = "Click me" }.Row(3)
40+
.Bold()
41+
.CenterHorizontal()
42+
.Invoke(btn => btn.Clicked += OnCounterClicked)
43+
.SemanticHint("Counts the number of times you click"),
44+
new Image() { Source = "dotnet_bot.png" }.Row(4)
45+
.Size(250, 310)
46+
.CenterHorizontal()
47+
.SemanticDesc("Cute dot net bot waving hi to you!"),
48+
}
49+
}.Padding(Device.RuntimePlatform switch { Device.iOS => new Thickness(30, 60, 30, 30), _ => new Thickness(30) })
8950
};
9051
}
9152

src/MauiBlazorApp/MauiBlazorApp/MauiBlazorApp.csproj

+7-15
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@
3333

3434
<ItemGroup>
3535
<!-- App Icon -->
36-
<MauiIcon Include="Resources\appicon.svg"
37-
ForegroundFile="Resources\appiconfg.svg"
38-
Color="#512BD4" />
36+
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" />
3937

4038
<!-- Splash Screen -->
41-
<MauiSplashScreen Include="Resources\appiconfg.svg"
42-
Color="#512BD4" />
39+
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" />
4340

4441
<!-- Images -->
4542
<MauiImage Include="Resources\Images\*" />
@@ -49,20 +46,15 @@
4946
</ItemGroup>
5047

5148
<ItemGroup>
52-
<PackageReference Include="CommunityToolkit.Maui.Markup"
53-
Version="1.0.0-pre5" />
54-
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded"
55-
Version="6.0.1" />
56-
<PackageReference Include="VijayAnand.MauiBlazor.Markup"
57-
Version="1.0.0-pre2" />
49+
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="1.0.0-pre7" />
50+
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.2" />
51+
<PackageReference Include="VijayAnand.MauiBlazor.Markup" Version="1.0.0-pre3" />
5852
</ItemGroup>
5953

6054
<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
6155
<!-- Required - WinUI does not yet have buildTransitive for everything -->
62-
<PackageReference Include="Microsoft.WindowsAppSDK"
63-
Version="1.0.0" />
64-
<PackageReference Include="Microsoft.Graphics.Win2D"
65-
Version="1.0.0.30" />
56+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
57+
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.0.30" />
6658
</ItemGroup>
6759

6860
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
<maui:MauiWinUIApplication
2-
x:Class="MauiBlazorApp.WinUI.App"
3-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:maui="using:Microsoft.Maui"
6-
xmlns:local="using:MauiBlazorApp.WinUI">
1+
<maui:MauiWinUIApplication xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:maui="using:Microsoft.Maui"
4+
xmlns:local="using:MauiBlazorApp.WinUI"
5+
x:Class="MauiBlazorApp.WinUI.App">
76

87
</maui:MauiWinUIApplication>
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="UTF-8"?>
22

33
<Package
44
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
55
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
66
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
77
IgnorableNamespaces="uap rescap">
88

9-
<Identity
10-
Name="c0e5a981-6a8b-4f3f-89ca-d2495f8a9131"
11-
Publisher="CN=User Name"
12-
Version="1.0.0.0" />
13-
14-
<Properties>
15-
<DisplayName>MauiBlazorApp</DisplayName>
16-
<PublisherDisplayName>Microsoft</PublisherDisplayName>
17-
<Logo>Assets\appiconStoreLogo.png</Logo>
18-
</Properties>
19-
20-
<Dependencies>
21-
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
22-
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
23-
</Dependencies>
24-
25-
<Resources>
26-
<Resource Language="x-generate"/>
27-
</Resources>
28-
29-
<Applications>
30-
<Application Id="App"
31-
Executable="$targetnametoken$.exe"
32-
EntryPoint="$targetentrypoint$">
33-
<uap:VisualElements
34-
DisplayName="MauiBlazorApp"
35-
Description="MauiBlazorApp"
36-
BackgroundColor="transparent"
37-
Square150x150Logo="Assets\appiconMediumTile.png"
38-
Square44x44Logo="Assets\appiconLogo.png">
39-
<uap:DefaultTile
40-
Wide310x150Logo="Assets\appiconWideTile.png"
41-
Square71x71Logo="Assets\appiconSmallTile.png"
42-
Square310x310Logo="Assets\appiconLargeTile.png"
43-
ShortName="MauiBlazorApp">
44-
<uap:ShowNameOnTiles>
45-
<uap:ShowOn Tile="square150x150Logo"/>
46-
<uap:ShowOn Tile="wide310x150Logo"/>
47-
</uap:ShowNameOnTiles>
48-
</uap:DefaultTile >
49-
<uap:SplashScreen Image="Assets\appiconfgSplashScreen.png" />
50-
</uap:VisualElements>
51-
</Application>
52-
</Applications>
53-
54-
<Capabilities>
55-
<rescap:Capability Name="runFullTrust" />
56-
</Capabilities>
9+
<Identity
10+
Name="c0e5a981-6a8b-4f3f-89ca-d2495f8a9131"
11+
Publisher="CN=User Name"
12+
Version="1.0.0.0" />
13+
14+
<Properties>
15+
<DisplayName>MauiBlazorApp</DisplayName>
16+
<PublisherDisplayName>Microsoft</PublisherDisplayName>
17+
<Logo>appiconStoreLogo.png</Logo>
18+
</Properties>
19+
20+
<Dependencies>
21+
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
22+
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
23+
</Dependencies>
24+
25+
<Resources>
26+
<Resource Language="x-generate"/>
27+
</Resources>
28+
29+
<Applications>
30+
<Application Id="App"
31+
Executable="$targetnametoken$.exe"
32+
EntryPoint="$targetentrypoint$">
33+
<uap:VisualElements
34+
DisplayName="MauiBlazorApp"
35+
Description="MauiBlazorApp"
36+
BackgroundColor="transparent"
37+
Square150x150Logo="appiconMediumTile.png"
38+
Square44x44Logo="appiconLogo.png">
39+
<uap:DefaultTile
40+
Wide310x150Logo="appiconWideTile.png"
41+
Square71x71Logo="appiconSmallTile.png"
42+
Square310x310Logo="appiconLargeTile.png"
43+
ShortName="MauiBlazorApp">
44+
<uap:ShowNameOnTiles>
45+
<uap:ShowOn Tile="square150x150Logo"/>
46+
<uap:ShowOn Tile="wide310x150Logo"/>
47+
</uap:ShowNameOnTiles>
48+
</uap:DefaultTile >
49+
<uap:SplashScreen Image="appiconfgSplashScreen.png" />
50+
</uap:VisualElements>
51+
</Application>
52+
</Applications>
53+
54+
<Capabilities>
55+
<rescap:Capability Name="runFullTrust" />
56+
</Capabilities>
5757

5858
</Package>

0 commit comments

Comments
 (0)