.NET 8 MAUI中如何修改AppShell菜单按钮背景色
如何修改.NET 8 MAUI中AppShell菜单按钮的背景色?
我想了解:
- 是否有可直接使用的属性来修改.NET 8 MAUI中AppShell菜单按钮的背景色?
- 是否可以通过自定义模板实现该需求?
最初尝试的模板方案
我曾在Platforms\Windows下的App.xaml中尝试以下模板:
<maui:MauiWinUIApplication.Resources> <DataTemplate x:Key="MauiAppTitleBarTemplate"> <Grid> <Border Canvas.ZIndex="1" VerticalAlignment="Stretch" Background="#0366d6" Margin="0,0,0,0"></Border> </Grid> </DataTemplate> </maui:MauiWinUIApplication.Resources>
需要修改背景色的AppShell菜单按钮

期望实现的效果

编辑:2024-06-30:我已实现预期效果,此前的模板方式并非正确方案,正确的Platforms\Windows下App.xaml文件内容如下:
<maui:MauiWinUIApplication.Resources> <ResourceDictionary> <Style TargetType="ContentControl" x:Key="WindowChromeStyle"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ContentControl"> <Grid x:Name="LayoutRoot" Background="#0366d6"> <ContentPresenter x:Name="ClientAreaPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Foreground="{TemplateBinding Foreground}" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary> </maui:MauiWinUIApplication.Resources>
内容的提问来源于stack exchange,提问作者JohannCoding
相关产品推荐
相关产品推荐

