update dotnet 9.0 windowsappsdk experimental2 add app titlebar
This commit is contained in:
1 parent
e734d89fb3
commit
33c0a002a2
6 files changed
+61
-39
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<RootNamespace>GZStudio.Core</RootNamespace>
|
||||
<Platforms>AnyCPU;x64;x86</Platforms>
|
||||
<Platforms>x86;x64;arm64;AnyCPU</Platforms>
|
||||
|
||||
@@ -47,6 +47,7 @@ public partial class App : Application
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
Host = Microsoft.Extensions.Hosting.Host.
|
||||
CreateDefaultBuilder().
|
||||
UseContentRoot(AppContext.BaseDirectory).
|
||||
@@ -99,10 +100,15 @@ public partial class App : Application
|
||||
|
||||
protected async override void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
MainWindow.AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
|
||||
MainWindow.AppWindow.TitleBar.ButtonBackgroundColor = Microsoft.UI.Colors.Transparent;
|
||||
|
||||
base.OnLaunched(args);
|
||||
|
||||
// cancel notification
|
||||
// App.GetService<IAppNotificationService>().Show(string.Format("AppNotificationSamplePayload".GetLocalized(), AppContext.BaseDirectory));
|
||||
|
||||
|
||||
await App.GetService<IActivationService>().ActivateAsync(args);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<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>
|
||||
<RootNamespace>GZStudio</RootNamespace>
|
||||
<ApplicationIcon>Assets/WindowIcon.ico</ApplicationIcon>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Platforms>x86;x64;arm64</Platforms>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<EnableMsixTooling>true</EnableMsixTooling>
|
||||
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
|
||||
<SupportedOSPlatformVersion>10.0.26100.0</SupportedOSPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Content Remove="Assets\WindowIcon.ico" />
|
||||
@@ -28,7 +30,7 @@
|
||||
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" 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.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="WinUIEx" Version="2.3.4" />
|
||||
</ItemGroup>
|
||||
@@ -49,4 +51,9 @@
|
||||
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
|
||||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<WindowsSdkPackageVersion>10.0.26100.38</WindowsSdkPackageVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<Thickness x:Key="NavigationViewContentGridBorderThickness">1,1,0,0</Thickness>
|
||||
<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="NavigationViewPageContentMargin">56,24,56,0</Thickness>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<Page
|
||||
x:Class="GZStudio.Views.ShellPage"
|
||||
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
@@ -10,39 +11,32 @@
|
||||
Loaded="OnLoaded">
|
||||
|
||||
<Grid>
|
||||
<Grid x:Name="AppTitleBar"
|
||||
Canvas.ZIndex="1"
|
||||
Height="{Binding ElementName=NavigationViewControl, Path=CompactPaneLength}"
|
||||
IsHitTestVisible="True"
|
||||
VerticalAlignment="Top">
|
||||
<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>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TitleBar x:Name="AppTitleBar" Title="GZStudio" Subtitle="preview" IsBackButtonVisible="True" IsPaneToggleButtonVisible="True" BorderBrush="WhiteSmoke" BorderThickness="2" CornerRadius="3"></TitleBar>
|
||||
<NavigationView
|
||||
Grid.Row="1"
|
||||
x:Name="NavigationViewControl"
|
||||
IsPaneToggleButtonVisible="False"
|
||||
Canvas.ZIndex="0"
|
||||
IsBackButtonVisible="Visible"
|
||||
IsBackButtonVisible="Collapsed"
|
||||
IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}"
|
||||
SelectedItem="{x:Bind ViewModel.Selected, Mode=OneWay}"
|
||||
IsSettingsVisible="True"
|
||||
ExpandedModeThresholdWidth="1280"
|
||||
DisplayModeChanged="NavigationViewControl_DisplayModeChanged"
|
||||
Header="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}">
|
||||
|
||||
<NavigationView.MenuItems>
|
||||
<!--
|
||||
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
|
||||
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
|
||||
|
||||
TODO: Update item icons by updating FontIcon.Glyph properties.
|
||||
https://docs.microsoft.com/windows/apps/design/style/segoe-fluent-icons-font#icon-list
|
||||
-->
|
||||
TODO: Update item icons by updating FontIcon.Glyph properties.
|
||||
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.Icon>
|
||||
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph=""/>
|
||||
@@ -58,20 +52,20 @@
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<TextBlock
|
||||
Text="{Binding}"
|
||||
Style="{ThemeResource TitleTextBlockStyle}" />
|
||||
Text="{Binding}"
|
||||
Style="{ThemeResource TitleTextBlockStyle}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</NavigationView.HeaderTemplate>
|
||||
<i:Interaction.Behaviors>
|
||||
<behaviors:NavigationViewHeaderBehavior
|
||||
DefaultHeader="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}">
|
||||
DefaultHeader="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}">
|
||||
<behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<TextBlock
|
||||
Text="{Binding}"
|
||||
Style="{ThemeResource TitleTextBlockStyle}" />
|
||||
Text="{Binding}"
|
||||
Style="{ThemeResource TitleTextBlockStyle}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
|
||||
|
||||
@@ -12,6 +12,8 @@ using Windows.System;
|
||||
namespace GZStudio.Views;
|
||||
|
||||
// TODO: Update NavigationViewItem titles and icons in ShellPage.xaml.
|
||||
|
||||
|
||||
public sealed partial class ShellPage : Page
|
||||
{
|
||||
public ShellViewModel ViewModel
|
||||
@@ -33,9 +35,22 @@ public sealed partial class ShellPage : Page
|
||||
App.MainWindow.ExtendsContentIntoTitleBar = true;
|
||||
App.MainWindow.SetTitleBar(AppTitleBar);
|
||||
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)
|
||||
{
|
||||
TitleBarHelper.UpdateTitleBar(RequestedTheme);
|
||||
@@ -46,18 +61,18 @@ public sealed partial class ShellPage : Page
|
||||
|
||||
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)
|
||||
{
|
||||
AppTitleBar.Margin = new Thickness()
|
||||
{
|
||||
Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1),
|
||||
Top = AppTitleBar.Margin.Top,
|
||||
Right = AppTitleBar.Margin.Right,
|
||||
Bottom = AppTitleBar.Margin.Bottom
|
||||
};
|
||||
//AppTitleBar.Margin = new Thickness()
|
||||
//{
|
||||
// Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1),
|
||||
// Top = AppTitleBar.Margin.Top,
|
||||
// Right = AppTitleBar.Margin.Right,
|
||||
// Bottom = AppTitleBar.Margin.Bottom
|
||||
//};
|
||||
}
|
||||
|
||||
private static KeyboardAccelerator BuildKeyboardAccelerator(VirtualKey key, VirtualKeyModifiers? modifiers = null)
|
||||
|
||||
Reference in new issue
Block a user