I am trying to set the Background to Transparent, however as you can see in the screen shot below when the mouse hovers over the ListBoxItem
it shows a blue Rectangle over the item:
I am using MVVM and my implementation is as follows:
<UserControl.Resources>
<Style x:Key="HyperLinkStyle" TargetType="{x:Type Hyperlink}">
<Setter Property="Foreground" Value="#FF0066CC"/>
<Setter Property="TextDecorations" Value="None" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="#FF0066CC"/>
<Setter Property="TextDecorations" Value="Underline" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Cursor" Value="Hand"/>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Grid>
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0, 10, 0, 0">
<ListBox x:Name="TeamListView" ItemsSource="{Binding Teams}" BorderThickness="0"
SelectionMode="Single" Background="Transparent">
<ListBox.ItemTemplate>
<DataTemplate>
<DataTemplate.Resources>
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="Transparent"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent"/>
</Trigger>
</Style.Triggers>
</Style>
</DataTemplate.Resources>
<TextBlock Margin="0, 0, 0, 5">
<Hyperlink Style="{Binding Source={StaticResource HyperLinkStyle}}"
Command="{Binding ElementName=TeamListView, Path=DataContext.ConnectToTeam}"
CommandParameter="{Binding}">
<TextBlock Text="{Binding Path=DisplayName}" />
</Hyperlink>
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
Notes:
The hyperlinkstyle is used to give a hyperlink feel to the hyperlink control with in listbox.
The listbox 'TeamListView' uses an ItemTemplate DataTemplate. The style for the ItemTemplate is ListBoxItem, by setting background to transparent onMouseHover the intention is to remove the blue with no color on hover.
What am I missing?