询问者
button被disable掉了就不能设置背景色了,但是我想设置怎么做呢?

问题
全部回复
-
Hi a013strife,
就想仁虎说的你需要修改模板和添加触发器来修改disabled按钮的背景色。或者,你也可以创建一个新的Button ControlTemplate,示例代码如下:
<Window.Resources> <Style TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Border x:Name="Overlay" CornerRadius="2"> <ContentPresenter/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="false"> <Setter TargetName="Overlay" Property="Background" Value="Pink"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <StackPanel> <Button Content="Button" IsEnabled="False"/> </StackPanel>
Have a nice day,
Kee Poppy [MSFT]
MSDN Community Support | Feedback to us
- 已标记为答案 Jie BaoModerator 2012年1月23日 2:33
- 取消答案标记 a013strife 2012年2月7日 6:57
- 已标记为答案 a013strife 2012年2月7日 6:58
- 取消答案标记 a013strife 2012年2月7日 6:58