Reputation: 3218
I have defined the following ListBox and am using the ShinyRed themes found here. However, I'm finding that row color only changes on mouse hover if I'm hovering over the label's text. I'd like to get the row to change color if I'm anywhere on the list item's line. How do I fix this?
<ListBox Grid.Row="1" ItemsSource="{Binding Categories}" ScrollViewer.CanContentScroll="False">
<ListBox.ItemTemplate>
<DataTemplate>
<Label Content={Binding DisplayName}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Upvotes: 0
Views: 539
Reputation: 184506
Use the ListBox.ItemContainerStyle
to make the items stretch.
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
(Also if it still only reacts to the text try setting the Label.Background
to Transparent
which hit-tests. And if it still don't work the ListBoxItem
control template of that theme is kinda whack)
Upvotes: 1