<TreeView.Resources>
<SolidColorBrush Color="Transparent" x:Key="{x:Static SystemColors.HighlightBrushKey}"/>
</TreeView.Resources>
Actually , i m having a TreeView in WPF App, as it contains various TreeViewItems , when I drag a treeview Item to DataGrid , that TreeViemItem gets grayed.
As i haven’t used XAML to create that treeview , I used C# code so I want to fix it using C# code only.
TreeView treeNode = new TreeView();
//In some loop
TreeViewItem childTreeNode = new TreeViewItem();
childTreeNode.Header = "Item 1";
childTreeNode.ToolTip = "File Path";
childTreeNode.Foreground = Brushes.Black;
childTreeNode.Background = Brushes.White;
treeNode.Items.Add(childTreeNode);
//End Loop
Now few TreeView Items get added into this TreeView.
Tree Looks fine but once focus removed from tree it’s selected treeviewitem got grayed
Refer this question also
How to Write Triggers and Setters for a TreeView through C# rather than XAML
You can do something like this.