当设置IsEnabled
为False
on时,ListView
我在控件周围得到一个像素厚的边框,带有颜色#F0F0F0
(在 Win7 上)。
我怀疑这是其中之一SystemColors
。如何将此边框设置BorderThickness
为0
,或者如果不这样SystemColors
做,我应该在我的样式中覆盖哪一个以将其更改为与控件背景相同?
我确定这里有多余的行,因为我一直在添加和删除试图解决问题的东西
<ListView ItemsSource="{Binding Path=Types}" SelectedItem="{Binding Path=SelectedType}" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsEnabled="{Binding Path=TypeCategoryIsSelected}" ItemContainerStyle="{StaticResource LVItemStyle}" BorderThickness="0" Background="{StaticResource aBackground}" SelectionMode="Single">
</ListView>
<SolidColorBrush x:Key="aBackground" Color="#FFFFE7" />
<DataTemplate x:Key="tDefaultTemplate">
<Border BorderBrush="#CDCDCD" BorderThickness="1" Background="#FFFFFF" Width="325" Margin="15,2,15,2" HorizontalAlignment="Stretch">
<DockPanel Margin="1,1,1,1" Height="28" HorizontalAlignment="Stretch" Width="Auto">
<DockPanel.Background>
<LinearGradientBrush StartPoint="1,0" EndPoint="1,1">
<GradientStop Color="#F2EFEF" Offset="0.0" />
<GradientStop Color="#F6F5F5" Offset="0.5" />
<GradientStop Color="#F8F8F8" Offset="1.0" />
</LinearGradientBrush>
</DockPanel.Background>
<TextBlock Margin="20,0,0,0" DockPanel.Dock="Left" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Path=Name}" />
</DockPanel>
</Border>
</DataTemplate>
<DataTemplate x:Key="tSelectedTemplate">
<Border BorderBrush="#DDA4AB" BorderThickness="1" Background="#FFFFFF" Width="325" Margin="15,2,15,2" HorizontalAlignment="Stretch">
<DockPanel Margin="1,1,1,1" Height="28" HorizontalAlignment="Stretch" Width="Auto">
<DockPanel.Background>
<LinearGradientBrush StartPoint="1,0" EndPoint="1,1">
<GradientStop Color="#FFE0E3" Offset="0.0" />
<GradientStop Color="#FFE8EA" Offset="0.5" />
<GradientStop Color="#F6EAEB" Offset="1.0" />
</LinearGradientBrush>
</DockPanel.Background>
<TextBlock Margin="20,0,0,0" DockPanel.Dock="Left" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Path=Name}" />
</DockPanel>
</Border>
</DataTemplate>
<Style TargetType="{x:Type ListViewItem}" x:Key="LVItemStyle">
<Setter Property="ContentTemplate" Value="{StaticResource tDefaultTemplate}" />
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FFFFE7"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#FFFFE7" />
</Style.Resources>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="ContentTemplate" Value="{StaticResource tSelectedTemplate}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="{StaticResource aBackground}" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type ListView}" x:Key="LVStyle">
<Setter Property="Background" Value="{StaticResource aBackground}" />
<Setter Property="BorderThickness" Value="0" />
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FFFFE7"/>
</Style.Resources>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="BorderBrush" Value="#FFFFE7"/>
<Setter Property="Background" Value="{StaticResource aBackground}" />
</Trigger>
</Style.Triggers>
</Style>