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

RadTreeView : application theme not being applied

4 Answers 214 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kenny
Top achievements
Rank 1
Kenny asked on 19 Dec 2016, 08:09 PM

I'm attempting to change the SelectedUnfocused VisualState.  I've extracted the style using Blend, made the correction for the Item Template Selector, and have set the Selected Unfocused Visual State to StoryBoard.TargetName="SelectionVisual".  So focused/unfocused look the same.

I'm also setting the StyleManager.ApplicationTheme to Windows7Theme in the window constructor prior to the InitializeComponent() call.

Simple xaml.  I would expect the highlights to be a blue-ish color.  However, they are the orange-ish color.

<Grid>
<telerik:RadTreeView ItemsSource="{Binding Nodes}"
ItemTemplateSelector="{StaticResource TreeViewTemplateSelector}"
ItemContainerStyle="{DynamicResource RadTreeViewItemStyle1 }"/>
</Grid>

 

However, if I do this, setting a simple property on the Item Container Style, the theme works.

<Grid>
<telerik:RadTreeView ItemsSource="{Binding Nodes}"
ItemTemplateSelector="{StaticResource TreeViewTemplateSelector}">
<telerik:RadTreeView.ItemContainerStyle>
<Style TargetType="{x:Type telerik:RadTreeViewItem}">
<Setter Property="IsExpanded" Value="True"></Setter>
</Style>
</telerik:RadTreeView.ItemContainerStyle>
</telerik:RadTreeView>
<!--ItemContainerStyle="{DynamicResource RadTreeViewItemStyle1 }"/>-->
</Grid>

 

I know the second case doesn't change the unfocused selection visual state, so how might I get theming to work when basing the Item Container Style on a complete style?

 

Thanks,
Kenny

 

4 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 22 Dec 2016, 04:15 PM
Hello Kenny,

Thanks for contacting us.
This is to inform you that I'm currently looking at your request but I'll need some more time to answer you.
I'll contact you again tomorrow with more information on the case.

Thanks in advance for your patience and understanding.

Regards,
Evgenia
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Evgenia
Telerik team
answered on 23 Dec 2016, 04:27 PM
Hi Kenny,

It seems that by applying your custom Style for the RadTreeViewItem via the ItemContainerStyle property where the Style itself is called as a resource it fails to get its preset Application theme and fallbacks to the default OfficeBlack theme (that's the reason why you see the orange-ish color).
Can you try explicitly setting the Theme for the custom style that you are setting like this:

<Style x:Key="RadTreeViewItemStyle1 " TargetType="telerik:RadTreeViewItem" telerik:StyleManager.BasedOn="Windows7">
 
....
 
<telerik:RadTreeView ItemsSource="{Binding Nodes}"
ItemTemplateSelector="{StaticResource TreeViewTemplateSelector}"
ItemContainerStyle="{StaticResource RadTreeViewItemStyle1 }"/>
</telerik:RadTreeView>
...


If this doesn't help I'd recommend that you send us a runnable version of your project where we can see your exact setup and guide you better. 

Regards,
Evgenia
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Kenny
Top achievements
Rank 1
answered on 27 Dec 2016, 02:27 PM

Thank you for your reply.  However, doing as you suggest results in a couple of complier errors.

Error The attachable property 'BasedOn' was not found in type 'StyleManager'.
Error The member "BasedOn" is not recognized or is not accessible. StyleStuff
Error The property 'StyleManager.BasedOn' does not exist in XML namespace 'http://schemas.telerik.com/2008/xaml/presentation'. Line 17 Position 96.

 

??

0
Petar Mladenov
Telerik team
answered on 30 Dec 2016, 08:18 AM
Hi Kenny,

The solution my colleague Evgenia mentioned is applicable to no-xaml scenarios and implicit styles. For more info on how to use this approach please check out the following resources:

Setting a Theme Using Implicit Styles
Editing Control Templates Implicit Styles

We encourage you to use implicit styles instead of StyleManager  This blog post explains why:

XAML Theming – Implicit Styles versus StyleManager
In your scenario with StyleManager - you have hit a limitation, you cannot extract non-default (default is OfficeBlack) styles if you set application theme in code behind. A way to extract Windows7 styles for RadTreeView is to set the Theme in xaml:

<telerik:RadTreeView telerik:StyleManager.Theme="Windows7"/>

We hope this helps, however, we strongly advice you pick the implicit styles approach.

Regards,
Petar Mladenov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
TreeView
Asked by
Kenny
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Kenny
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or