C# XAML Flyout 更改标题背景颜色
Posted
技术标签:
【中文标题】C# XAML Flyout 更改标题背景颜色【英文标题】:C# XAML Flyout change headerbackground color 【发布时间】:2014-06-10 13:57:03 【问题描述】:我在 C# 中使用 XAML 制作了一个浮出控件,现在我想更改为标题和后退按钮保留的空间的背景颜色。但该区域未在弹出页面中定义。有谁知道如何更改标题和后退按钮周围面板的背景颜色?
<SettingsFlyout
x:Class="CatalogApp.FlyoutControl.Login"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CatalogApp.FlyoutControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
IconSource="Assets/SmallLogo.png"
Title="Login"
d:DesignWidth="346">
<!-- This StackPanel acts as a root panel for vertical layout of the content sections -->
<StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" RenderTransformOrigin="0.458,1.194" Width="250" >
<!-- The StackPanel(s) below define individual content sections -->
<!-- Content Section 1 Maring: left, up, down, right-->
<TextBlock x:Name="LBLuserName" TextWrapping="Wrap" Text="Username" FontSize="18" Margin="10,0,0,0"/>
<TextBox x:Name="TbUserName" TextWrapping="Wrap" Margin="10,0,0,0"/>
<TextBlock x:Name="LBLpassWord" TextWrapping="Wrap" FontSize="18" Text="Password" Margin="10,20,0,0"/>
<TextBox x:Name="TbPassWord" TextWrapping="Wrap" Margin="10,0,0,0" KeyDown="TbPassWord_KeyDown"/>
<TextBlock x:Name="TAWebService" TextWrapping="Wrap" Text="WebserviceURL (Inclusief HTTP://)" Margin=" 10,20,0,0" FontSize="15"/>
<TextBox x:Name="TBWebServiceURL" TextWrapping="Wrap" Margin="10,0,0,20" PlaceholderText=""/>
<Button x:Name="BTCheckConnection" Content="Check connectie" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,0,100,0" Click="BTCheckConnection_Click"/>
<TextBlock x:Name="TBConnection" TextWrapping="Wrap" Margin="10,20,0,0"/>
<Button x:Name="btTrue" Content="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="btTrue_Click"/>
<Button x:Name="btFalse" Content="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="btFalse_Click"/>
<!-- Content Section 1-->
<!-- Define more Content Sections below as necessary -->
</StackPanel>
【问题讨论】:
【参考方案1】:您只需添加HeaderBackground
喜欢;
<SettingsFlyout
x:Class="CatalogApp.FlyoutControl.Login"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CatalogApp.FlyoutControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
IconSource="Assets/SmallLogo.png"
Title="Login"
d:DesignWidth="346"
HeaderBackground="Green">
干杯
【讨论】:
以上是关于C# XAML Flyout 更改标题背景颜色的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 xaml Themeresource 属性更改 winrt 应用程序的背景颜色和强调颜色
无论布局背景颜色如何,如何保留 Windows.UI.Xaml.Controls.Image 内容颜色?