Problem can be reproduced by the following code:
<ListView>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="BorderBrush" Value="{x:Null}" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFEDC4" />
<Setter Property="BorderBrush" Value="{x:Null}" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.Items>
<ListViewItem Height="70">Some item</ListViewItem>
<ListViewItem Height="70">Some item</ListViewItem>
<ListViewItem Height="70">Some item</ListViewItem>
<ListViewItem Height="70">Some item</ListViewItem>
</ListView.Items>
</ListView>
The control has problems to get mouse clicks properly. Clicking item text works well and selects the item. Clicking anywhere outside of the text (so outside of the TextBox but inside ListViewItem) works 80% of the time, but every 5th time it doesn’t. The item doesn’t get selected. It’s not only visual style wrong, the item really doesn’t get selected which can be checked with keyboard arrow keys.
Everything started after adding triggers. Removing IsMouseOver trigger helps.
What could be wrong here?
Use
instead of
{x:Null}. Otherwise mouse events will not be catched.