ITPub博客

首页 > > > wpf 触发器为什么没效果

wpf 触发器为什么没效果

作者:flynike 时间:2019-09-11 13:43:13 0 删除 编辑

如下:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        Title="MainWindow" Height="350" Width="525">
    
    <Window.Resources>
        <Style TargetType="Button">
            <Style.Triggers>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="FontSize" Value="36"></Setter>
                    <Setter Property="Background" Value="Red"></Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    
    <Grid>
        <Button Background="Green"   Content="Hight Value" x:Name="btnVisible"  Margin="250,154,167,114" />
    </Grid>
</Window>

定义一个style 里面有个触发器当IsPressed为ture的时候(按钮按下)  设置字体大小和背景颜色

但是实际运行效果为什么 点击后字体变了而背景颜色却没有呢?

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2618/viewspace-3123578/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-07-26

  • 博文量
    205
  • 访问量
    9820