Let me first start with that it is not a good practice to specify a custom style in code behind. If you still consider setting a custom style of the RadTreeViewItems in code behind you can take a look at the sample example below.
Style customStyle =
Setter setter =
setter.Property = TextBlock.ForegroundProperty;
setter.Value = Brushes.Green;
Setter setter2 =
setter2.Property = RadTreeViewItem.IsExpandedProperty;
.myTree.ItemContainerStyle = customStyle;
By setting the custom style to the ItemContainerStyle
property of the RadTreeView you can applied it to all tree items in the tree.
Another approach that you can try is to create a custom ResourceDictionary where you specify the custom style and applied to the RadTreeViewItems.
You can take a look at the following MSDN resources which could be in handy for your case.
Hope this information is useful.
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer
and share your thoughts.