Thank you for getting back to us and elaborating on your requirements. I can understand why you'd rather have the style defined in MainWindow.xaml
however you will still have to make sure and update this style when you dynamically change the themes.
This means that you will have to clear the MainWindow Resources
and the RadTreeView ItemContainerStyle
properties before changing the theme and you will then have to reapply them to make sure the custom style is based on the proper new theme style.
This is why it might be better to not use an ItemContainerStyle
and make your custom style implicit. It would also be easier to move the style in a separate ResourceDictionary
as it's easier to clear the MergedDictionaries
collection in the MainWindow
and then add the resource dictionary back as soon as the theme changes.
I demonstrated this approach in the attached sample. As the TreeViewItemStyle.xaml
contains the custom RadTreeViewItem
style and is defined within the MainWindow Resources
, you can use bindings as you need to. The DataContext
of the MainWindow
component will be properly propagated to the style setters and properties.
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>