2013-08-07 3 views
2

У меня есть проблема с Trigger и свойство IsMouseOver в следующем фрагментеBorder IsMouseOver Trigger не работает

<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 здесь два изображения, которые показывают поведение:

This works This doesn't work

ответ

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> 
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> 
Смежные вопросы