update dotnet 9.0 windowsappsdk experimental2 add app titlebar

This commit is contained in:
jianxin committed 2024-09-01 16:32:41 +08:00
1 parent e734d89fb3
commit 33c0a002a2
6 files changed
+61 -39

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<RootNamespace>GZStudio.Core</RootNamespace> <RootNamespace>GZStudio.Core</RootNamespace>
<Platforms>AnyCPU;x64;x86</Platforms> <Platforms>AnyCPU;x64;x86</Platforms>
<Platforms>x86;x64;arm64;AnyCPU</Platforms> <Platforms>x86;x64;arm64;AnyCPU</Platforms>
+6
View File
@@ -47,6 +47,7 @@ public partial class App : Application
{ {
InitializeComponent(); InitializeComponent();
Host = Microsoft.Extensions.Hosting.Host. Host = Microsoft.Extensions.Hosting.Host.
CreateDefaultBuilder(). CreateDefaultBuilder().
UseContentRoot(AppContext.BaseDirectory). UseContentRoot(AppContext.BaseDirectory).
@@ -99,9 +100,14 @@ public partial class App : Application
protected async override void OnLaunched(LaunchActivatedEventArgs args) protected async override void OnLaunched(LaunchActivatedEventArgs args)
{ {
MainWindow.AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
MainWindow.AppWindow.TitleBar.ButtonBackgroundColor = Microsoft.UI.Colors.Transparent;
base.OnLaunched(args); base.OnLaunched(args);
// cancel notification // cancel notification
// App.GetService<IAppNotificationService>().Show(string.Format("AppNotificationSamplePayload".GetLocalized(), AppContext.BaseDirectory)); // App.GetService<IAppNotificationService>().Show(string.Format("AppNotificationSamplePayload".GetLocalized(), AppContext.BaseDirectory));
await App.GetService<IActivationService>().ActivateAsync(args); await App.GetService<IActivationService>().ActivateAsync(args);
} }
+9 -2
View File
@@ -1,19 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows10.0.22621.0</TargetFramework> <TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion> <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>GZStudio</RootNamespace> <RootNamespace>GZStudio</RootNamespace>
<ApplicationIcon>Assets/WindowIcon.ico</ApplicationIcon> <ApplicationIcon>Assets/WindowIcon.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;arm64</Platforms> <Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers> <RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<UseRidGraph>true</UseRidGraph>
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile> <PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWinUI>true</UseWinUI> <UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling> <EnableMsixTooling>true</EnableMsixTooling>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained> <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<SupportedOSPlatformVersion>10.0.26100.0</SupportedOSPlatformVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Content Remove="Assets\WindowIcon.ico" /> <Content Remove="Assets\WindowIcon.ico" />
@@ -28,7 +30,7 @@
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240821" /> <PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240821" />
<PackageReference Include="CommunityToolkit.WinUI.Triggers" Version="8.1.240821" /> <PackageReference Include="CommunityToolkit.WinUI.Triggers" Version="8.1.240821" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240802000" /> <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240701003-experimental2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" /> <PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageReference Include="WinUIEx" Version="2.3.4" /> <PackageReference Include="WinUIEx" Version="2.3.4" />
</ItemGroup> </ItemGroup>
@@ -49,4 +51,9 @@
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'"> <PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu> <HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<WindowsSdkPackageVersion>10.0.26100.38</WindowsSdkPackageVersion>
</PropertyGroup>
</Project> </Project>
+1 -1
View File
@@ -25,7 +25,7 @@
<Thickness x:Key="NavigationViewContentGridBorderThickness">1,1,0,0</Thickness> <Thickness x:Key="NavigationViewContentGridBorderThickness">1,1,0,0</Thickness>
<CornerRadius x:Key="NavigationViewContentGridCornerRadius">8,0,0,0</CornerRadius> <CornerRadius x:Key="NavigationViewContentGridCornerRadius">8,0,0,0</CornerRadius>
<Thickness x:Key="NavigationViewContentMargin">0,48,0,0</Thickness> <Thickness x:Key="NavigationViewContentMargin">0,0,0,0</Thickness>
<Thickness x:Key="NavigationViewHeaderMargin">56,34,0,0</Thickness> <Thickness x:Key="NavigationViewHeaderMargin">56,34,0,0</Thickness>
<Thickness x:Key="NavigationViewPageContentMargin">56,24,56,0</Thickness> <Thickness x:Key="NavigationViewPageContentMargin">56,24,56,0</Thickness>
+20 -26
View File
@@ -1,5 +1,6 @@
<Page <Page
x:Class="GZStudio.Views.ShellPage" x:Class="GZStudio.Views.ShellPage"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -10,39 +11,32 @@
Loaded="OnLoaded"> Loaded="OnLoaded">
<Grid> <Grid>
<Grid x:Name="AppTitleBar" <Grid.RowDefinitions>
Canvas.ZIndex="1" <RowDefinition Height="Auto" />
Height="{Binding ElementName=NavigationViewControl, Path=CompactPaneLength}" <RowDefinition Height="*" />
IsHitTestVisible="True" </Grid.RowDefinitions>
VerticalAlignment="Top"> <TitleBar x:Name="AppTitleBar" Title="GZStudio" Subtitle="preview" IsBackButtonVisible="True" IsPaneToggleButtonVisible="True" BorderBrush="WhiteSmoke" BorderThickness="2" CornerRadius="3"></TitleBar>
<Image Source="/Assets/WindowIcon.ico"
HorizontalAlignment="Left"
Width="16"
Height="16" />
<TextBlock x:Name="AppTitleBarText"
VerticalAlignment="Center"
TextWrapping="NoWrap"
Style="{StaticResource CaptionTextBlockStyle}"
Margin="28,0,0,0"/>
</Grid>
<NavigationView <NavigationView
Grid.Row="1"
x:Name="NavigationViewControl" x:Name="NavigationViewControl"
IsPaneToggleButtonVisible="False"
Canvas.ZIndex="0" Canvas.ZIndex="0"
IsBackButtonVisible="Visible" IsBackButtonVisible="Collapsed"
IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}" IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.Selected, Mode=OneWay}" SelectedItem="{x:Bind ViewModel.Selected, Mode=OneWay}"
IsSettingsVisible="True" IsSettingsVisible="True"
ExpandedModeThresholdWidth="1280" ExpandedModeThresholdWidth="1280"
DisplayModeChanged="NavigationViewControl_DisplayModeChanged" DisplayModeChanged="NavigationViewControl_DisplayModeChanged"
Header="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}"> Header="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}">
<NavigationView.MenuItems> <NavigationView.MenuItems>
<!-- <!--
TODO: Update item titles by updating <x:Uid>.Content entries in Strings/en-us/Resources.resw. TODO: Update item titles by updating <x:Uid>.Content entries in Strings/en-us/Resources.resw.
https://docs.microsoft.com/windows/uwp/app-resources/localize-strings-ui-manifest#refer-to-a-string-resource-identifier-from-xaml https://docs.microsoft.com/windows/uwp/app-resources/localize-strings-ui-manifest#refer-to-a-string-resource-identifier-from-xaml
TODO: Update item icons by updating FontIcon.Glyph properties. TODO: Update item icons by updating FontIcon.Glyph properties.
https://docs.microsoft.com/windows/apps/design/style/segoe-fluent-icons-font#icon-list https://docs.microsoft.com/windows/apps/design/style/segoe-fluent-icons-font#icon-list
--> -->
<NavigationViewItem x:Uid="Shell_AppList" helpers:NavigationHelper.NavigateTo="GZStudio.ViewModels.AppListViewModel"> <NavigationViewItem x:Uid="Shell_AppList" helpers:NavigationHelper.NavigateTo="GZStudio.ViewModels.AppListViewModel">
<NavigationViewItem.Icon> <NavigationViewItem.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe7c3;"/> <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe7c3;"/>
@@ -58,20 +52,20 @@
<DataTemplate> <DataTemplate>
<Grid> <Grid>
<TextBlock <TextBlock
Text="{Binding}" Text="{Binding}"
Style="{ThemeResource TitleTextBlockStyle}" /> Style="{ThemeResource TitleTextBlockStyle}" />
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</NavigationView.HeaderTemplate> </NavigationView.HeaderTemplate>
<i:Interaction.Behaviors> <i:Interaction.Behaviors>
<behaviors:NavigationViewHeaderBehavior <behaviors:NavigationViewHeaderBehavior
DefaultHeader="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}"> DefaultHeader="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}">
<behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate> <behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
<DataTemplate> <DataTemplate>
<Grid> <Grid>
<TextBlock <TextBlock
Text="{Binding}" Text="{Binding}"
Style="{ThemeResource TitleTextBlockStyle}" /> Style="{ThemeResource TitleTextBlockStyle}" />
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate> </behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
+24 -9
View File
@@ -12,6 +12,8 @@ using Windows.System;
namespace GZStudio.Views; namespace GZStudio.Views;
// TODO: Update NavigationViewItem titles and icons in ShellPage.xaml. // TODO: Update NavigationViewItem titles and icons in ShellPage.xaml.
public sealed partial class ShellPage : Page public sealed partial class ShellPage : Page
{ {
public ShellViewModel ViewModel public ShellViewModel ViewModel
@@ -33,9 +35,22 @@ public sealed partial class ShellPage : Page
App.MainWindow.ExtendsContentIntoTitleBar = true; App.MainWindow.ExtendsContentIntoTitleBar = true;
App.MainWindow.SetTitleBar(AppTitleBar); App.MainWindow.SetTitleBar(AppTitleBar);
App.MainWindow.Activated += MainWindow_Activated; App.MainWindow.Activated += MainWindow_Activated;
AppTitleBarText.Text = "AppDisplayName".GetLocalized(); //AppTitleBarText.Text = "AppDisplayName".GetLocalized();
//AppTitleBar.Loaded += MyTitleBar_Loaded;
} }
//private void MyTitleBar_Loaded(object sender, RoutedEventArgs e)
//{
// // Parts get delay loaded. If you have the parts, make them visible.
// VisualStateManager.GoToState(AppTitleBar, "SubtitleTextVisible", false);
// VisualStateManager.GoToState(AppTitleBar, "HeaderVisible", false);
// VisualStateManager.GoToState(AppTitleBar, "ContentVisible", false);
// VisualStateManager.GoToState(AppTitleBar, "FooterVisible", false);
// // Run layout so we re-calculate the drag regions.
// AppTitleBar.InvalidateMeasure();
//}
private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{ {
TitleBarHelper.UpdateTitleBar(RequestedTheme); TitleBarHelper.UpdateTitleBar(RequestedTheme);
@@ -46,18 +61,18 @@ public sealed partial class ShellPage : Page
private void MainWindow_Activated(object sender, WindowActivatedEventArgs args) private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
{ {
App.AppTitlebar = AppTitleBarText as UIElement; //App.AppTitlebar = AppTitleBarText as UIElement;
} }
private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args) private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
{ {
AppTitleBar.Margin = new Thickness() //AppTitleBar.Margin = new Thickness()
{ //{
Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1), // Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1),
Top = AppTitleBar.Margin.Top, // Top = AppTitleBar.Margin.Top,
Right = AppTitleBar.Margin.Right, // Right = AppTitleBar.Margin.Right,
Bottom = AppTitleBar.Margin.Bottom // Bottom = AppTitleBar.Margin.Bottom
}; //};
} }
private static KeyboardAccelerator BuildKeyboardAccelerator(VirtualKey key, VirtualKeyModifiers? modifiers = null) private static KeyboardAccelerator BuildKeyboardAccelerator(VirtualKey key, VirtualKeyModifiers? modifiers = null)