【问题标题】:Change the color of an InkToolbar [UWP]更改 InkToolbar 的颜色 [UWP]
【发布时间】:2017-08-11 05:54:40
【问题描述】:

我正在尝试使 UWP InkToolbar 的按钮透明,但更改 background 属性不会更改控件的颜色,是否有其他方法可以更改工具栏按钮的颜色?

我目前使用的 XAML 代码是这样的:

<InkToolbar x:Name="inkToolbar" TargetInkCanvas="{x:Bind inkCanvas}" HorizontalAlignment="Center" VerticalAlignment="Top" Background="Transparent"/>

【问题讨论】:

  • 你是如何设置背景的?如果在代码中请显示相关的sn-ps。

标签: c# xaml uwp uwp-xaml


【解决方案1】:

最简单的方法是像这样覆盖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>

【讨论】:

    猜你喜欢
    • 2016-07-04
    • 1970-01-01
    • 1970-01-01
    • 2018-06-28
    • 2020-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-12
    相关资源
    最近更新 更多