小编S.K*_*S.K的帖子

选中但更改焦点时更改WPF treeViewItem背景颜色

我正在尝试更改TreeViewItem背景颜色,当它选择但失去焦点.我看到了一些类似的问题: WPF TreeViewItem Background ,但我无法使用它......

这是我的树视图Xaml代码:

>     <UserControl x:Class="Ednfi.Setup.Presentation.Views.TreeViewViews.StationTree"
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
> xmlns:behaviour="clr-namespace:Ednfi.Setup.Presentation.Extensions;assembly=Ednfi.Setup.Presentation"
> xmlns:nodes="clr-namespace:Ednfi.Setup.Presentation.ViewModels.TreeViewViewModels.Nodes"
> mc:Ignorable="d"
> xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
> xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
> d:DesignHeight="226" d:DesignWidth="227"
> xmlns:ml="clr-namespace:Ednfi.Setup.Presentation.ml_resources">
>         <TreeView Margin="10 0 10 20" ItemsSource="{Binding Path=Root.Children}" VirtualizingStackPanel.IsVirtualizing="True"
> VirtualizingStackPanel.VirtualizationMode="Recycling">
>     
>     
>             <TreeView.ItemContainerStyle>
>                 <Style TargetType="{x:Type TreeViewItem}">
>                     <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}"/>
>                     <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" />
>                 </Style>
>             </TreeView.ItemContainerStyle>
>             <TreeView.Resources>
>                 <Style TargetType="{x:Type TreeViewItem}">
>                     <Setter Property="Background" Value="Transparent" />
>                     <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, …
Run Code Online (Sandbox Code Playgroud)

wpf treeview xaml

12
推荐指数
2
解决办法
2万
查看次数

标签 统计

treeview ×1

wpf ×1

xaml ×1