2

我对以下代码段中的aTrigger和属性有疑问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这是两个显示行为的图像:

这有效 这不起作用

4

2 回答 2

0

如果您删除 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>
于 2014-09-18T10:14:07.827 回答
0

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

<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>
于 2014-11-12T10:56:24.487 回答