我在以下代码段中遇到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
的下半部分这里有两个显示行为的图像:
答案 0 :(得分: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>
答案 1 :(得分: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>