Reputation: 4885
I have a sort of tile system for my application. See the below code:
<WrapPanel Grid.Column="0" Grid.Row="1">
<DockPanel Style="{StaticResource Panel}">
<Label Content="Upload"/>
<Image Width="40">
<Image.Source>
<BitmapImage DecodePixelWidth="40" UriSource="images/download.png" />
</Image.Source>
</Image>
</DockPanel>
</WrapPanel>
As you can see, I have got the main container ([icode]WrapPanel[/icode]), and then I have got multiple [icode]DockPanel[/icode]'s which makeup the tile itself.
For some reason when I mouseover the DockPanel, the IsMouseOver trigger doesn't trigger, but it does when I mouse over any of it's children. Once triggered it remains triggered until my mouse leaves the DockPanel.
Here is the style:
<Style x:Key="Panel" TargetType="DockPanel">
<Setter Property="Margin" Value="4" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Height" Value="118" />
<Setter Property="Width" Value="118" />
<Setter Property="LastChildFill" Value="True" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FF212121" />
</Trigger>
</Style.Triggers>
<Style.Resources>
<Style TargetType="Label">
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="Margin" Value="3" />
<Setter Property="DockPanel.Dock" Value="Bottom" />
</Style>
</Style.Resources>
</Style>
Any ideas?
Upvotes: 2
Views: 1952
Reputation: 7585
Try to set DockPanel's background to Transparent. When background is null, WPF will not include it in hit test.
Upvotes: 9