Mahapps Metro 按钮焦点 BorderBrush
Mahapps Metro Button Focus BorderBrush
我正在寻找一些东西来设置 Mahapps
Metro Window 中按钮的 BorderBrush
颜色,但我找不到东西。有没有办法为边框设置新颜色?
您可以创建覆盖默认模板的样式,可以用任何您喜欢的颜色替换颜色,并根据需要添加更多触发器:
<Style TargetType="Button" x:Key="DefaultButtonStyle">
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Background" Value="#3a3a3a"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="metro:ButtonHelper.PreserveTextCase" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
Margin="{TemplateBinding Margin}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#424242"/>
</Trigger>
</Style.Triggers>
</Style>
好的,所以我用 Aleksandr Albert 的回答做到了。我只错过了 属性 IsFocused
<Style x:Key="ButtonMentorPlusStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource AccentedSquareButtonStyle}">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#0D6373" />
<Setter Property="FontSize" Value="14" />
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="FontStyle" Value="Normal" />
<Setter Property="MinWidth" Value="100" />
<Setter Property="MinHeight" Value="28" />
<Setter Property="Controls:ButtonHelper.PreserveTextCase" Value="True" />
<Setter Property="Padding" Value="10, 0, 10, 0" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
谢谢大家
我正在寻找一些东西来设置 Mahapps
Metro Window 中按钮的 BorderBrush
颜色,但我找不到东西。有没有办法为边框设置新颜色?
您可以创建覆盖默认模板的样式,可以用任何您喜欢的颜色替换颜色,并根据需要添加更多触发器:
<Style TargetType="Button" x:Key="DefaultButtonStyle">
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Background" Value="#3a3a3a"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="metro:ButtonHelper.PreserveTextCase" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
Margin="{TemplateBinding Margin}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#424242"/>
</Trigger>
</Style.Triggers>
</Style>
好的,所以我用 Aleksandr Albert 的回答做到了。我只错过了 属性 IsFocused
<Style x:Key="ButtonMentorPlusStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource AccentedSquareButtonStyle}">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#0D6373" />
<Setter Property="FontSize" Value="14" />
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="FontStyle" Value="Normal" />
<Setter Property="MinWidth" Value="100" />
<Setter Property="MinHeight" Value="28" />
<Setter Property="Controls:ButtonHelper.PreserveTextCase" Value="True" />
<Setter Property="Padding" Value="10, 0, 10, 0" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
谢谢大家