我正在使用MahApp.Metro测试wpf应用程序。不知何故,我无法改变ToggleSwitch的风格。我只想改变简单的属性,如前景或背景的开关。我做错了什么?
Mainwindow.xaml
<Style x:Key="flyoutToggleSwitchStyle" TargetType="{x:Type Controls:ToggleSwitch}" BasedOn="{StaticResource {x:Type Controls:ToggleSwitch}}">
<Setter Property="BorderBrush" Value="WhiteSmoke"/>
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="Yellow"/>
<Setter Property="OnLabel" Value="Yes"/> <!--<<<---THIS WORKS!!-->
<Setter Property="OffLabel" Value="No"/>
</Style>
<Controls:ToggleSwitch Style="{StaticResource flyoutToggleSwitchStyle}">
<Controls:ToggleSwitch.Header>
<TextBlock>
Test
</TextBlock>
</Controls:ToggleSwitch.Header>
</Controls:ToggleSwitch>发布于 2014-12-01 23:21:22
现在有了一个名为ToggleSwitch的新属性SwitchForeground,它允许更改ON位置的颜色(在v0.14上测试)。示例:
<controls:ToggleSwitch SwitchForeground="{StaticResource MyGreen}" />发布于 2013-10-21 08:38:37
问题是,在Mahapps.Metro ToggleSwitch中,大多数属性不能在样式内更改,因为原始模板定义中没有定义TemplateBinding或键。
因此,只有通过创建新模板才能更改样式。为此,必须更改ToggleSwitch和ToggleSwitchButton模板。
https://stackoverflow.com/questions/19269998
复制相似问题