Reputation: 1358
I have a WPF Listview containing another UserControl. It works fine, but I cannot remove the mouse blu highlight and selected.
Here the code:
<UserControl.Resources>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border
BorderBrush="Transparent"
BorderThickness="0"
Background="{TemplateBinding Background}">
<GridViewRowPresenter HorizontalAlignment="Stretch" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Width="Auto" Margin="0" Content="{TemplateBinding Content}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate DataType="{x:Type vm:ElementViewModel}" x:Key="ElementTemplate">
<vw:ElementView />
</DataTemplate>
</UserControl.Resources>
<GroupBox Header="{x:Static Translate:Translate.CreateLoop}">
<ListView ItemsSource="{Binding Path=ElementList, UpdateSourceTrigger=PropertyChanged}"
ItemTemplate="{StaticResource ElementTemplate}"
Background="{StaticResource EnvLayout}"
BorderBrush="Transparent">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Style.Resources>
<!--Foreground for Selected ListViewItem-->
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
<!--Background for Selected ListViewItem-->
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="ItemBackgroundHover" Color="Transparent"/>
</Style.Resources>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</GroupBox>
the datatemplate is used to bind the view with the corresponding viewmodel. Here the mouse over style I'd like to remove
Upvotes: 0
Views: 663
Reputation: 1555
Try this
Add a style
<UserControl.Resources>
<Style x:Key="MyStyle" TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
Remove your style and instead
ItemContainerStyle="{StaticResource MyStyle}"
Upvotes: 2