【问题标题】:Border IsMouseOver Trigger not working边框 IsMouseOver 触发器不起作用
【发布时间】:2013-08-07 13:27:58
【问题描述】:

我对以下 sn-p 中的 Trigger 和属性 IsMouseOver 有疑问

<Border Name="PART_Logo" Background="{DynamicResource Accent}" Width="36" Height="36" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,76,0">
    <Border.InputBindings>
        <MouseBinding Command="presentation:Commands.LogoClickCommand" Gesture="LeftClick" />
    </Border.InputBindings>
    <Border.Style>
        <Style TargetType="Border">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="BitmapEffect">
                        <Setter.Value>
                            <BlurBitmapEffect Radius="3" KernelType="Gaussian"/>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Border.Style>
    <Image Source="{TemplateBinding Logo}" Stretch="UniformToFill">
        <Image.Style>
            <Style TargetType="Image">
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="BitmapEffect">
                            <Setter.Value>
                                <BlurBitmapEffect Radius="3" KernelType="Gaussian"/>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Image.Style>
        <Image.InputBindings>
            <MouseBinding Command="presentation:Commands.LogoClickCommand" Gesture="LeftClick" />
        </Image.InputBindings>
    </Image>
</Border>

它只适用于Border 的下半部分,这里有两张显示行为的图像:

【问题讨论】:

    标签: wpf triggers effects


    【解决方案1】:

    如果你删除 Border.InputBindings 和 Image.InputBindings 就会起作用

    请删除以下代码,希望它可以工作。

    <Border.InputBindings>
            <MouseBinding Command="presentation:Commands.LogoClickCommand" Gesture="LeftClick" />
    </Border.InputBindings>
    
    <Image.InputBindings>
                <MouseBinding Command="presentation:Commands.LogoClickCommand" Gesture="LeftClick" />
    </Image.InputBindings>
    

    【讨论】:

      【解决方案2】:

      您已直接在边框上设置背景。删除它并尝试在样式内设置边框

      <Border.Style>
              <Setter Property="Background" Value="{StaticResource Accent}">
              <Style TargetType="Border">
                  <Style.Triggers>
                      <Trigger Property="IsMouseOver" Value="True">
                          <Setter Property="BitmapEffect">
                              <Setter.Value>
                                  <BlurBitmapEffect Radius="3" KernelType="Gaussian"/>
                              </Setter.Value>
                          </Setter>
                      </Trigger>
                  </Style.Triggers>
              </Style>
          </Border.Style>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-12
        • 2018-04-10
        相关资源
        最近更新 更多