今天,我開始教我自己如何創建一個WPF應用程序(最終)WPF的ListView樣式邊框
,所以我開始習慣它,但我已經打了一下碰釘子與樣式列表視圖。
在這上面的圖片你可以看到它完美的工作(約選擇無邊框)
然而,在第二張照片,你可以看到周圍的選擇一個邊陲..看來這只是當我使用鍵盤轉到列表中的下一個項目時發生。
有什麼我在樣式中失蹤,所以我可以擺脫這個邊界?
代碼:(記得我纔開始學習,所以今天它可能是混亂的)
列表視圖樣式
<Style TargetType="{x:Type ListView}">
<Setter Property="BorderThickness" Value="0" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderThickness" Value="0" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderThickness" Value="0" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="#4b0037" />
<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.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="images/selection.png"/>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="0" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="images/selection.png"/>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="#FFFFFF" />
</Trigger>
</Style.Triggers>
</Style>
列表視圖XAML
<ListView Background="transparent" Margin="10 10 10 10" x:Name="Mylist" HorizontalAlignment="Stretch" VerticalContentAlignment="center" VerticalAlignment="Stretch" BorderBrush="Transparent">
<ListView.View>
<GridView>
<GridViewColumn Header="img" Width="150" DisplayMemberBinding="{Binding img}" />
<GridViewColumn Header="name" Width="150" DisplayMemberBinding="{Binding name}" />
<GridViewColumn Header="path" Width="150" DisplayMemberBinding="{Binding path}" />
</GridView>
</ListView.View>
</ListView>
非常感謝你,先生,這解決了我的問題。 – Mattigins