以wpf按钮样式执行鼠标操作的setter属性是什么?

时间:2012-09-30 09:07:50

标签: wpf button triggers mouse

我正在尝试更改每个状态的按钮外观,现在我有IsEnabled IsPressed IsMouseOver,但鼠标左键发布的Tigger Property是什么?

<Style x:Key="GoogleGreyButton" TargetType="{x:Type Button}">
                <ControlTemplate.Triggers>
                   <Trigger Property="IsMouseOver" Value="True">
                        <!--Some setters here-->

                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <!--Some setters here-->

                    </Trigger>
                    <Trigger Property="IsEnabled" Value="True">
                        <!--Some setters here-->

                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

2 个答案:

答案 0 :(得分:0)

您需要更多的风格才能展示任何内容,但请尝试以下活动:

<Style x:Key="GoogleGreyButton" TargetType="{x:Type Button}">
    <EventSetter Event="MouseLeftButtonUp" Handler="Button_MouseLeftButtonUp"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <!--Some setters here-->

                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <!--Some setters here-->

                    </Trigger>
                    <Trigger Property="IsEnabled" Value="True">
                        <!--Some setters here-->

                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

答案 1 :(得分:0)

您可以使用EventTrigger

<EventTrigger RoutedEvent="PreviewMouseLeftButtonUp">
    <BeginStoryboard>
        <Storyboard>
            ...
        </Storyboard>
    </BeginStoryboard>
</EventTrigger>