Skip to content

Commit 7c45e62

Browse files
BlazorMAUI
1 parent df6ebf1 commit 7c45e62

Some content is hidden

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

68 files changed

+279
-305
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@
6060
#*.pdf diff=astextplain
6161
#*.PDF diff=astextplain
6262
#*.rtf diff=astextplain
63-
#*.RTF diff=astextplain
63+
#*.RTF diff=astextplain

MyAppMAUI/App.xaml App.xaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
22
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
33
xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls"
4-
xmlns:local="clr-namespace:MyAppMAUI"
5-
x:Class="MyAppMAUI.App"
4+
xmlns:local="clr-namespace:MAUIBlazor"
5+
x:Class="MAUIBlazor.App"
66
windows:Application.ImageDirectory="Assets">
77
<Application.Resources>
88
<ResourceDictionary>

App.xaml.cs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace MAUIBlazor;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new MainPage();
10+
}
11+
}

Data/WeatherForecast.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace MAUIBlazor.Data;
2+
3+
public class WeatherForecast
4+
{
5+
public DateTime Date { get; set; }
6+
7+
public int TemperatureC { get; set; }
8+
9+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10+
11+
public string Summary { get; set; }
12+
}

Data/WeatherForecastService.cs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace MAUIBlazor.Data;
2+
3+
public class WeatherForecastService
4+
{
5+
private static readonly string[] Summaries = new[]
6+
{
7+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
8+
};
9+
10+
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
11+
{
12+
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
13+
{
14+
Date = startDate.AddDays(index),
15+
TemperatureC = Random.Shared.Next(-20, 55),
16+
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
17+
}).ToArray());
18+
}
19+
}
20+

MyAppMAUI/MyAppMAUI.csproj MAUIBlazor.csproj

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
55
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041</TargetFrameworks>
66
<OutputType>Exe</OutputType>
7-
<RootNamespace>MyAppMAUI</RootNamespace>
7+
<RootNamespace>MAUIBlazor</RootNamespace>
88
<UseMaui>true</UseMaui>
99
<SingleProject>true</SingleProject>
10+
<ImplicitUsings>enable</ImplicitUsings>
1011
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
1112
<EnableDefaultCssItems>false</EnableDefaultCssItems>
1213

1314
<!-- Display name -->
14-
<ApplicationTitle>MyAppMAUI</ApplicationTitle>
15+
<ApplicationTitle>MAUIBlazor</ApplicationTitle>
1516

1617
<!-- App Identifier -->
17-
<ApplicationId>com.companyname.MyAppMAUI</ApplicationId>
18+
<ApplicationId>com.companyname.mauiblazor</ApplicationId>
1819

1920
<!-- Versions -->
2021
<ApplicationVersion>1</ApplicationVersion>
2122

2223
<!-- Required for C# Hot Reload -->
23-
<UseInterpreter Condition="'$(Configuration)' == 'Debug'">True</UseInterpreter>
24+
<UseInterpreter Condition="'$(Configuration)' == 'Debug' AND '$(TargetFramework)' != 'net6.0-ios'">True</UseInterpreter>
2425

2526
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-ios'">14.2</SupportedOSPlatformVersion>
2627
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">14.0</SupportedOSPlatformVersion>
@@ -31,10 +32,7 @@
3132

3233
<ItemGroup>
3334
<!-- App Icon -->
34-
<MauiIcon
35-
Include="Resources\appicon.svg"
36-
ForegroundFile="Resources\appiconfg.svg"
37-
Color="#512BD4" />
35+
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" />
3836

3937
<!-- Splash Screen -->
4038
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" />
@@ -48,17 +46,19 @@
4846

4947
<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
5048
<!-- Required - WinUI does not yet have buildTransitive for everything -->
51-
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0-preview3" />
52-
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.0.29-preview3" />
49+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
50+
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.0.30" />
5351
</ItemGroup>
5452

5553
<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
5654
<OutputType>WinExe</OutputType>
57-
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
55+
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
5856
</PropertyGroup>
5957

6058
<ItemGroup>
6159
<Content Remove="Properties\launchSettings.json" />
6260
</ItemGroup>
6361

62+
<ProjectExtensions><VisualStudio><UserProperties XamarinHotReloadGenericExceptionInfoBarMAUIBlazorHideInfoBar="True" /></VisualStudio></ProjectExtensions>
63+
6464
</Project>

MyAppMAUI.sln MAUIBlazor.sln

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio Version 17
33
VisualStudioVersion = 17.0.31611.283
44
MinimumVisualStudioVersion = 10.0.40219.1
5-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyAppMAUI", "MyAppMAUI\MyAppMAUI.csproj", "{1183888C-D490-4229-8789-7E04845FFD4D}"
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MAUIBlazor", "MAUIBlazor.csproj", "{13F4A4B1-029F-4063-A91E-DF26AA594D66}"
66
EndProject
77
Global
88
GlobalSection(SolutionConfigurationPlatforms) = preSolution
99
Debug|Any CPU = Debug|Any CPU
1010
Release|Any CPU = Release|Any CPU
1111
EndGlobalSection
1212
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13-
{1183888C-D490-4229-8789-7E04845FFD4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14-
{1183888C-D490-4229-8789-7E04845FFD4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
15-
{1183888C-D490-4229-8789-7E04845FFD4D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
16-
{1183888C-D490-4229-8789-7E04845FFD4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{1183888C-D490-4229-8789-7E04845FFD4D}.Release|Any CPU.Build.0 = Release|Any CPU
18-
{1183888C-D490-4229-8789-7E04845FFD4D}.Release|Any CPU.Deploy.0 = Release|Any CPU
13+
{13F4A4B1-029F-4063-A91E-DF26AA594D66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{13F4A4B1-029F-4063-A91E-DF26AA594D66}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{13F4A4B1-029F-4063-A91E-DF26AA594D66}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
16+
{13F4A4B1-029F-4063-A91E-DF26AA594D66}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{13F4A4B1-029F-4063-A91E-DF26AA594D66}.Release|Any CPU.Build.0 = Release|Any CPU
18+
{13F4A4B1-029F-4063-A91E-DF26AA594D66}.Release|Any CPU.Deploy.0 = Release|Any CPU
1919
EndGlobalSection
2020
GlobalSection(SolutionProperties) = preSolution
2121
HideSolutionNode = FALSE

MyAppMAUI/Main.razor Main.razor

File renamed without changes.

MyAppMAUI/MainPage.xaml MainPage.xaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
22
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
33
xmlns:b="clr-namespace:Microsoft.AspNetCore.Components.WebView.Maui;assembly=Microsoft.AspNetCore.Components.WebView.Maui"
4-
xmlns:local="clr-namespace:MyAppMAUI"
5-
x:Class="MyAppMAUI.MainPage"
4+
xmlns:local="clr-namespace:MAUIBlazor"
5+
x:Class="MAUIBlazor.MainPage"
66
BackgroundColor="{DynamicResource PageBackgroundColor}">
77

88
<b:BlazorWebView HostPage="wwwroot/index.html">

MainPage.xaml.cs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace MAUIBlazor;
2+
3+
public partial class MainPage : ContentPage
4+
{
5+
public MainPage()
6+
{
7+
InitializeComponent();
8+
}
9+
}

MauiProgram.cs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.AspNetCore.Components.WebView.Maui;
2+
using MAUIBlazor.Data;
3+
4+
namespace MAUIBlazor;
5+
6+
public static class MauiProgram
7+
{
8+
public static MauiApp CreateMauiApp()
9+
{
10+
var builder = MauiApp.CreateBuilder();
11+
builder
12+
.RegisterBlazorMauiWebView()
13+
.UseMauiApp<App>()
14+
.ConfigureFonts(fonts =>
15+
{
16+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
17+
});
18+
19+
builder.Services.AddBlazorWebView();
20+
builder.Services.AddSingleton<WeatherForecastService>();
21+
22+
return builder.Build();
23+
}
24+
}

MyAppMAUI/App.xaml.cs

-17
This file was deleted.

MyAppMAUI/Data/WeatherForecast.cs

-15
This file was deleted.

MyAppMAUI/Data/WeatherForecastService.cs

-24
This file was deleted.

MyAppMAUI/MainPage.xaml.cs

-13
This file was deleted.

MyAppMAUI/MauiProgram.cs

-30
This file was deleted.

MyAppMAUI/Pages/FetchData.razor

-46
This file was deleted.

MyAppMAUI/Platforms/Android/MainActivity.cs

-11
This file was deleted.

MyAppMAUI/Platforms/Android/MainApplication.cs

-19
This file was deleted.

0 commit comments

Comments
 (0)