Hi,
I have some questions to know the best practice to reuse styles overriding theme's ones.
My solution is organized as this:
- The main exe is in Smag.MSH.csproj
- My custom controls are in Smag.UI.Wpf
- All the styles are defined in Smag.Styles.csproj
I'm using implicit themes, so Smag.Style embeds:
- xaml files from Windows 8 theme for all used controls
- xaml files overriding default themes for some controls
eg: in MyRadGridView.xaml
<Style x:Key="NoBorderGridView" BasedOn="{StaticResource {x:Type telerik:RadGridView}}" TargetType="{x:Type telerik:RadGridView}">
The main exe merge the theme's and my own resources like this:
<Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <!-- telerik all the corresponding xaml are included here --> <ResourceDictionary Source="pack://application:,,,/Smag.MSH.Style;component/Telerik/System.Windows.xaml" /> <ResourceDictionary Source="pack://application:,,,/Smag.MSH.Style;component/Telerik/Telerik.Windows.Controls.GridView.xaml" /> <!-- The real list is cut for brievity -->
<!-- Own controls styles --> <ResourceDictionary Source="pack://application:,,,/Smag.MSH.Style;component/ControlsStyles/MyRadGridView.xaml" />
What is the best pratices to reuse all the styles (theme's default one en those i have overrided) in Smag.UI.Wpf ?
The default style are currently not found:
<Style BasedOn="{StaticResource RadListBoxStyle}" TargetType="{x:Type local:ListBox}" />Raise an error saying RadListBoxStyle is not found, but the right xaml is included in app.xaml
Event using this way, it doesn't work:
<Setter Property="Background" Value="{telerik:Windows8Resource ResourceKey={x:Static telerik:Windows8ResourceKey.MainBrush}}" />
As it's a DLL, there is no app.xaml to merge ressources, doing it in each control like this seems to me not being performant:
<ResourceDictionary xmlns="..." xmlns:x="..." xmlns:i="..." xmlns:local="clr-namespace:Smag.UI.Wpf.Controls" xmlns:telerik="..."> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/System.Windows.xaml" /> <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.xaml" /> <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Data.xaml" /> <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Input.xaml" /> </ResourceDictionary.MergedDictionaries></p>
Thanks for some more guidelines, the official documentation is not enough.