【发布时间】:2015-09-01 18:04:31
【问题描述】:
选中 ToggleButton 后,应将 Button 设置为禁用并且前景色应更改。以下方法不起作用:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ToggleButton Content="Hallo" Margin="113,97,72,46" >
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="IsEnabled" Value="True"/>
<Setter Property="IsChecked" Value="False"/>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="IsEnabled" Value="False"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="Green"/>
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
</ToggleButton>
</Grid>
我该怎么做?
【问题讨论】:
-
我在 Visual Studio 中粘贴了你的代码,它工作了
-
前景色变成绿色了吗?
-
不可能,文本颜色默认为灰色。你能想象为什么吗?
-
从
发布所有的 xaml,你在使用后面的代码吗? -
我不知道,你是道尔顿吗?
标签: wpf