WPF:在ExpressionBlend中,自定义一个按钮,如果我更改一个状态的外观,其他状态的外观将相同

WPF:在ExpressionBlend中,自定义一个按钮,如果我更改一个状态的外观,其他状态的外观将相同,wpf,expression-blend,visualstatemanager,Wpf,Expression Blend,Visualstatemanager,在Expression Blend 4中,我想自定义一个按钮 在窗口中选择按钮,右键单击它,编辑模板->编辑副本,在button.xaml中选择位置,该位置是resources dictionary。接下来删除Chrome,添加边框,在边框下方添加ContentPresenter。接下来,选择边框,然后在状态面板中,选择鼠标悬停并更改背景和“边框笔刷”。但其他人的外观也会更改为与鼠标悬停状态相同 我在“属性”面板中使用系统笔刷资源指定笔刷 如下图所示: 我刚改变了鼠标悬停状态的背景 但其他国家的

在Expression Blend 4中,我想自定义一个按钮

在窗口中选择按钮,右键单击它,编辑模板->编辑副本,在button.xaml中选择位置,该位置是resources dictionary。接下来删除Chrome,添加边框,在边框下方添加ContentPresenter。接下来,选择边框,然后在状态面板中,选择鼠标悬停并更改背景和“边框笔刷”。但其他人的外观也会更改为与鼠标悬停状态相同

我在“属性”面板中使用系统笔刷资源指定笔刷

如下图所示: 我刚改变了鼠标悬停状态的背景

但其他国家的背景也发生了变化:

Button.xaml

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
    <Style x:Key="ButtonFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- Resource dictionary entries should be defined here. -->
    <LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#F3F3F3" Offset="0"/>
        <GradientStop Color="#EBEBEB" Offset="0.5"/>
        <GradientStop Color="#DDDDDD" Offset="0.5"/>
        <GradientStop Color="#CDCDCD" Offset="1"/>
    </LinearGradientBrush>
    <SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
    <Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
        <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border BorderBrush="{DynamicResource {x:Static SystemColors.ActiveCaptionTextBrushKey}}" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver"/>
                                <VisualState x:Name="Pressed"/>
                                <VisualState x:Name="Disabled"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentPresenter/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="true"/>
                        <Trigger Property="ToggleButton.IsChecked" Value="true"/>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="#ADADAD"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

我必须解决它。首先,在状态面板中选择一个状态,然后切换到“对象和时间线面板”并添加边框,然后更改其外观

像这样: