Hi,
I try to follow the thread about CustomStyle (http://www.telerik.com/help/wpf/styling-apperance-custom-styles-themes-runtime.html) by replacing the RadButton by a RadGridView.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="telerik:RadGridView" BasedOn="{StaticResource RadGridViewStyle}">
<Setter Property="Background" Value="Red"/>
</Style>
</ResourceDictionary>
When I click on Button to switch the theme, an exception is raised ('System.Windows.Markup.XamlParseException') because it's not able to resolve the RadGridViewStyle. It seems that it can not resolve staticresource presents in another files (app.xaml), i don't understand why it's work with RadButton and not RadGridView.
Thanks for feedback.
Regards
I try to follow the thread about CustomStyle (http://www.telerik.com/help/wpf/styling-apperance-custom-styles-themes-runtime.html) by replacing the RadButton by a RadGridView.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="telerik:RadGridView" BasedOn="{StaticResource RadGridViewStyle}">
<Setter Property="Background" Value="Red"/>
</Style>
</ResourceDictionary>
When I click on Button to switch the theme, an exception is raised ('System.Windows.Markup.XamlParseException') because it's not able to resolve the RadGridViewStyle. It seems that it can not resolve staticresource presents in another files (app.xaml), i don't understand why it's work with RadButton and not RadGridView.
Thanks for feedback.
Regards
7 Answers, 1 is accepted
0
Hi,
Have you merged the respective ResourceDictionary for RadGridView?
<ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.GridView.xaml"/>
You can also check our online documentation on Implicit Styles for a further reference on how to apply styling.
Regards,
Didie
Telerik
Have you merged the respective ResourceDictionary for RadGridView?
<ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.GridView.xaml"/>
You can also check our online documentation on Implicit Styles for a further reference on how to apply styling.
Regards,
Didie
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
luc
Top achievements
Rank 1
answered on 22 Aug 2014, 02:29 PM
Hi,
You can found a sample project here
The goal is to follow the post about custom style and not to reference telerik theme in custom xaml file directly. Like it's work for RadButtonStyle, I suppose it can be work for others controls.
Thanks.
Regards
You can found a sample project here
The goal is to follow the post about custom style and not to reference telerik theme in custom xaml file directly. Like it's work for RadButtonStyle, I suppose it can be work for others controls.
Thanks.
Regards
0
Hi,
The reason why RadGridView does not respect the changed Theme's settings is that you have not merged the respected resource dictionary.
You should do similarly to how it is done for the Telerik.Windows.Controls.xaml dictionary (the one needed for displaying RadButton).
For example:
I updated the sample project and you can find it attached.
Regards,
Didie
Telerik
The reason why RadGridView does not respect the changed Theme's settings is that you have not merged the respected resource dictionary.
You should do similarly to how it is done for the Telerik.Windows.Controls.xaml dictionary (the one needed for displaying RadButton).
For example:
private
void
Office_Black_Click(
object
sender, RoutedEventArgs e)
{
Application.Current.Resources.MergedDictionaries.Clear();
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary()
{
Source =
new
Uri(
"/Telerik.Windows.Themes.Office_Black;component/Themes/System.Windows.xaml"
, UriKind.RelativeOrAbsolute)
});
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary()
{
Source =
new
Uri(
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.xaml"
, UriKind.RelativeOrAbsolute)
});
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary()
{
Source =
new
Uri(
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.GridView.xaml"
, UriKind.RelativeOrAbsolute)
});
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary()
{
Source =
new
Uri(
"/CustomStyles;component/Themes/Custom.xaml"
, UriKind.RelativeOrAbsolute)
});
}
I updated the sample project and you can find it attached.
Regards,
Didie
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
luc
Top achievements
Rank 1
answered on 30 Aug 2014, 04:38 PM
Hi,
Indeed I miss the griedview.xaml, thank you.
Instead of enumerate each xaml in code, I create a Resource Dictionary page with content :
and in the code I try to load only the new resource
This way raise again an exception when trying to resolve RadGridViewStyle. Do you see why ?
Thank
Regards
Indeed I miss the griedview.xaml, thank you.
Instead of enumerate each xaml in code, I create a Resource Dictionary page with content :
<
ResourceDictionary.MergedDictionaries
>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Office_Black;component/Themes/System.Windows.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.GridView.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.Input.xaml"
/>
<
ResourceDictionary
Source
=
"/CustomStyles;component/Themes/Custom.xaml"
/>
</
ResourceDictionary.MergedDictionaries
>
and in the code I try to load only the new resource
Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary()
{ Source =
new
Uri(
"/Dictionary1.xaml"
, UriKind.RelativeOrAbsolute) });
This way raise again an exception when trying to resolve RadGridViewStyle. Do you see why ?
Thank
Regards
0
Hi,
I notice that you first clear all the MergedDictionaries. Is it possible that this is the reason for the crash?
If not, may I ask you to update the demo project and send it back to me? That way I will be able to advise further.
Regards,
Didie
Telerik
I notice that you first clear all the MergedDictionaries. Is it possible that this is the reason for the crash?
If not, may I ask you to update the demo project and send it back to me? That way I will be able to advise further.
Regards,
Didie
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
0
Hi Luc,
I am indeed able to reproduce the issue. The exception should be thrown due to some problem with loading of the ResourceDictionaries one after another in the correct order during the first layout update.
I can suggest you loading the dictionaries separately, or not clearing the already loaded ones:
Regards,
Didie
Telerik
I am indeed able to reproduce the issue. The exception should be thrown due to some problem with loading of the ResourceDictionaries one after another in the correct order during the first layout update.
I can suggest you loading the dictionaries separately, or not clearing the already loaded ones:
private
void
AllInOne_Click(
object
sender, RoutedEventArgs e)
{
//Application.Current.Resources.MergedDictionaries.Clear();
Application.Current.Resources.MergedDictionaries.Add(
new
ResourceDictionary()
{
Source =
new
Uri(
"/CustomStyles;component/AllInOne.xaml"
, UriKind.RelativeOrAbsolute)
});
}
Regards,
Didie
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.