Xaml 如何改变前景+;禁用按钮时的边框颜色windows 8?
我在堆栈面板中有一个按钮Xaml 如何改变前景+;禁用按钮时的边框颜色windows 8?,xaml,winrt-xaml,Xaml,Winrt Xaml,我在堆栈面板中有一个按钮 <StackPanel> <Button x:Name="CreateBtn" Content="Create" Style="{StaticResource PopUpButton}" Width="120" HorizontalAlignment="Right" Margin="0 60 30 0" Command="{Binding SaveCardTypeCommand}" /> </StackPanel>
<StackPanel>
<Button x:Name="CreateBtn" Content="Create" Style="{StaticResource PopUpButton}" Width="120" HorizontalAlignment="Right" Margin="0 60 30 0" Command="{Binding SaveCardTypeCommand}" />
</StackPanel>
这就是在文件中使用样式
<Style x:Key="PopUpButton" TargetType="Button">
<Setter Property="Foreground" Value="#1172b7"/>
<Setter Property="BorderBrush" Value="#1172b7"/>
<Setter Property="BorderThickness" Value="3"/>
</Style>
当按钮被禁用时,我需要将内容和边框笔刷的颜色更改为红色
我该怎么做
致以最诚挚的问候使用expression blend编辑按钮的默认模板并自定义视觉状态。可以为每个视觉状态定义动画
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="Border">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<SolidColorBrush Color="Red"/>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<SolidColorBrush Color="Red"/>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
是否从后端代码禁用按钮?将可视状态组添加到控件模板的根元素中。可以向其添加多个可视状态。Expression blend可帮助您轻松添加或编辑状态。