WPF 样式 触发器 小栗子

 <Window.Resources>
        <Style TargetType="Button">
            <Style.Setters>
                <Setter Property="Height" Value="30" />
                <Setter Property="Width" Value="50" />
                <Setter Property="Content" Value="Button" />
                <Setter Property="Foreground" Value="Red" />
            </Style.Setters>
            <Style.Triggers>
                <!--<Trigger Property="IsMouseOver" Value="True">
                    <Trigger.Setters>
                        <Setter Property="FontSize" Value="30" />
                        <Setter Property="Width" Value="100" />
                        <Setter Property="Height" Value="80" />
                    </Trigger.Setters>
                </Trigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsFocused" Value="True" />
                        <Condition Property="IsMouseOver" Value="True" />
                    </MultiTrigger.Conditions>
                    <MultiTrigger.Setters>
                        <Setter Property="Foreground" Value="Aquamarine" />
                    </MultiTrigger.Setters>
                </MultiTrigger>-->
                <EventTrigger RoutedEvent="Mouse.MouseEnter">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation
                                    Storyboard.TargetProperty="FontSize"
                                    To="30"
                                    Duration="0:0:0.2" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <StackPanel>
            <Button />
            <Button />
            <Button />
            <Button />
        </StackPanel>
    </Grid>

 

 

 

posted @ 2021-11-10 14:33  吃葡萄不吐葡萄脾  阅读(35)  评论(0编辑  收藏  举报