Up vote 0 down vote favorite share g+ share fb share tw.
How to Add following XAML based trigger to TreeView from Code behind rather than XAML. WPF's default behavior is to change the TreeViewItem to gray when the ContextMenu opens, but like virtually everything else in WPF you can override this: Create an attached property ContextMenuOpened In the TreeViewItem Style, bind ContextMenuOpened to "ContextMenu. IsOpen" Add a trigger that changes the brush when ContextMenuOpened and IsSelected are both true Here's the attached property: public class TreeViewCustomizer : DependencyObject { public static bool GetContextMenuOpened(DependencyObject obj) { return (bool)obj.
GetValue(ContextMenuOpenedProperty); } public static void SetContextMenuOpened(DependencyObject obj, bool value) { obj. SetValue(ContextMenuOpenedProperty, value); } public static readonly DependencyProperty ContextMenuOpenedProperty = DependencyProperty. RegisterAttached("ContextMenuOpened", typeof(bool), typeof(TreeViewCustomizer)); } Here's the setter in the style: Here's the trigger: All trees in my application are created at Runtime through C# code.
I want to do all the above work throughC# code as I have created my tree at Runtime by using following code TreeView _objTreeView = new TreeView(); Reference Question : WPF TreeViewItem Context Menu Unhighlights Item c# .net wpf xaml dependency-properties link|improve this question asked Jan 23 at 9:01Abhishek Gupta1,213224 78% accept rate.
Done it using following statements SolidColorBrush colorBrush = new SolidColorBrush(Colors. DodgerBlue); myTreeView.Resources. Add(SystemColors.
ControlBrushKey, colorBrush); :).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.