当前位置: 代码迷 >> Silverlight >> WPF属性触发器不发生效果
  详细解决方案

WPF属性触发器不发生效果

热度:3492   发布时间:2013-02-26 00:00:00.0
WPF属性触发器不产生效果
我XAML页面设置这样一个触发器,为什么没有起到效果呢

<Window x:Class="ProDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" Name="FrmMain">
    <Window.Resources>
        <Style TargetType="{x:Type Button}">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="Black"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <Button Content="Button" Height="43" Margin="12,48,356,218" Name="btn" Width="135" Click="btn_Click" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="12,20,0,0" Name="txt" VerticalAlignment="Top" Width="479" />
    </Grid>
</Window>

鼠标移到按钮上面,应该是要变成橙色才对,但是一点反应都没有,请问是咋回事呀
------解决方案--------------------------------------------------------
 <Style TargetType="{x:Type RibbonLib:RibbonButton}">
        <Setter Property="Focusable" Value="False"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RibbonLib:RibbonButton}">
                    <Grid Cursor="Hand">
                        <!--背景色-->
                        <Border x:Name="back" Opacity="0.8" CornerRadius="3" BitmapEffect="{DynamicResource {ComponentResourceKey RibbonLib:Skins, RibbonActiveButtonBitmapEffect}}" Background="{DynamicResource {ComponentResourceKey RibbonLib:Skins, RibbonActiveButtonBrush}}">
                            <!--前景色及边框-->
                            <Border x:Name="fore" BorderThickness="1" CornerRadius="3" BorderBrush="{DynamicResource {ComponentResourceKey RibbonLib:Skins, RibbonActiveButtonBorderBrush}}">
                                <Border.Background>
  相关解决方案