更改InkToolbar的颜色[UWP]
问题描述:
我试图使UWP InkToolbar
的按钮透明,但更改background
属性不会更改控件的颜色,是否有另一种方法可以更改颜色工具栏的按钮?更改InkToolbar的颜色[UWP]
我目前使用的XAML代码是这样的:
<InkToolbar x:Name="inkToolbar" TargetInkCanvas="{x:Bind inkCanvas}" HorizontalAlignment="Center" VerticalAlignment="Top" Background="Transparent"/>
答
最简单的方法是重写主题背景刷在你App.xaml
这样
<Application.Resources>
<SolidColorBrush x:Key="InkToolbarButtonBackgroundThemeBrush">Transparent</SolidColorBrush>
</Application.Resources>
如果你想要更多的控制,您可以包含所有按钮样式为BasedOn
的样式。
<Application.Resources>
<Style x:Key="InkToolbarCommonButtonStyle"
TargetType="ToggleButton">
<Setter Property="MinWidth"
Value="{ThemeResource InkToolbarButtonWidth}" />
<Setter Property="MinHeight"
Value="{ThemeResource InkToolbarButtonHeight}" />
<Setter Property="MaxWidth"
Value="{ThemeResource InkToolbarButtonWidth}" />
<Setter Property="MaxHeight"
Value="{ThemeResource InkToolbarButtonHeight}" />
<Setter Property="BorderThickness"
Value="0" />
<Setter Property="Background"
Value="Transparent" />
<Setter Property="Foreground"
Value="{ThemeResource InkToolbarButtonForegroundThemeBrush}" />
<Setter Property="FocusVisualMargin"
Value="-3" />
</Style>
</Application.Resources>
你是如何设置背景的?如果在代码中,请显示相关的片段。 –