首页 新闻 搜索 专区 学院

WPF 触发器 Button的Content

0
悬赏园豆:5 [待解决问题]

就是想不通,所以问下各位大神

<Button Width="100" Height="30" Content="World">
            <Button.Style>
                <Style TargetType="Button">
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Content">
                                <Setter.Value>
                                    <TextBlock Text="Hello"></TextBlock>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>

这样为什么没有效果?

UncleNull的主页 UncleNull | 初学一级 | 园豆:3
提问于:2013-06-21 23:11
< >
分享
所有回答(1)
1

<Button Content="before mouse over" Height="50" Width="150"
                    HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border CornerRadius="5" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"
                                BorderThickness="1" BorderBrush="Black" Background="{TemplateBinding Background}"
                                Style="{TemplateBinding Style}">
                            <ContentPresenter x:Name="contentpre01" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Content" TargetName="contentpre01" Value="after mouse over"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Button.Template>
            </Button>

给你个思路,剩下的自己研究呗。

无晴雪 | 园豆:201 (菜鸟二级) | 2013-06-28 15:55

3Q,谢啦

支持(1) 反对(0) UncleNull | 园豆:3 (初学一级) | 2013-06-28 18:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册