WPF的TreeView的节点选中但失去焦点样式

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_37080285/article/details/83620110

点击效果在这里插入图片描述
失去焦点后在这里插入图片描述
怎么做到可以让失去焦点的时候颜色也不变呢
你让他在活动和非活动TreeView中,所选项目的前景色和背景色是相同的就行了

<TreeView.ItemContainerStyle>
  <Style TargetType="{x:Type TreeViewItem}">
    <Style.Resources>
      <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="DodgerBlue"/>
      <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="White"/>
      <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="DodgerBlue"/>
      <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="White"/>
    </Style.Resources>        
  </Style>
</TreeView.ItemContainerStyle>

ListBox等也同理

猜你喜欢

转载自blog.csdn.net/m0_37080285/article/details/83620110