This is a migrated thread and some comments may be shown as answers.

Removing the "selected" colors and borders for a RadTreeViewItem

1 Answer 49 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Josh Gough
Top achievements
Rank 1
Josh Gough asked on 02 Jul 2010, 03:20 PM
Hello,

One thing we'd like to do is to not retain any highlighted background color or borders around the RadTreeViewItem when the user clicks it.
I've seen the information here about replacing the default style:

http://www.telerik.com/help/silverlight/radtreeview-styling-and-appearance-styling-radtreeviewitem.html

This seems like overkill to have to do all this in blend just to change a few brushes.

Is there any way to do this through code dynamically or in Visual Studio at least?

Thank you,
Josh



1 Answer, 1 is accepted

Sort by
0
Josh Gough
Top achievements
Rank 1
answered on 02 Jul 2010, 03:43 PM
I solved this in a differentish way:

        Dictionary<MenuItemNode, RadTreeViewItem> _radTreeViewItems = new Dictionary<MenuItemNode, RadTreeViewItem>();
        void MenuItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e) {
            var menuItemNode = e.PreparedItem.DataContext as MenuItemNode;
            if (menuItemNode != null) {
                e.PreparedItem.IsExpanded = menuItemNode.IsExpanded;
                _radTreeViewItems[menuItemNode] = e.PreparedItem;
            }
        }

        private void MenuItemClicked(object sender, RadRoutedEventArgs e) {
            if (sender is RadTreeView) {
                var menu = sender as RadTreeView;
                if (menu.SelectedItem is MenuItemNode) {
                    var menuItem = menu.SelectedItem as MenuItemNode;
                    var treeViewItem = _radTreeViewItems[menuItem];
                    treeViewItem.IsSelected = false;
                    if (menuItem.NavigateAction != null) {
                        menuItem.NavigateAction();
                    }
                }
            }
        }
Tags
TreeView
Asked by
Josh Gough
Top achievements
Rank 1
Answers by
Josh Gough
Top achievements
Rank 1
Share this question
or