Hi:
I use themes mechanism of Q2 in my silverlight project. It works fine between radcontrols component. Follow the way:
StyleManager.ApplicationTheme = ThemeManager.FromName("Vista"); |
As of bussiness demand, i add some custom components in my project. Some of them are totally new while others extend radcontrols component. Such as:
EFRegion: a similar component to Expandar ( new )
EFGrid: extends RadGridView (extends)
public class EFRegion : AnimatedExpander |
{ |
...... |
public EFRegion() |
{ |
...... |
DefaultStyleKey = typeof( EFRegion ); |
...... |
} |
...... |
} |
public class EFGrid : RadGridView |
{ |
...... |
public EFGrid() |
{ |
...... |
DefaultStyleKey = typeof(EFGrid); |
...... |
} |
...... |
} |
I also create a theme project DeepBlue, like Vista/Summer/Office_Blue themes project in Q2. In DeepBlue project, i have the following style resources:
Generic.xaml
EFRegion.xaml
EFGrid.xaml
The contents of the above resources are:
Generic.xaml: |
...... |
<ResourceDictionary.MergedDictionaries> |
...... |
<ResourceDictionary Source="/MyAssemblyName;component/Themes/EFGrid.xaml" /> |
...... |
</ResourceDictionary.MergedDictionaries> |
...... |
EFRegion.xaml: |
...... |
<Style TargetType="local:EFRegion"> |
</Style> |
...... |
EFGrid.xaml:( the content is similar to RadGridView.xaml, the key difference is TargetType ) |
...... |
<ControlTemplate x:Key="RadGridViewTemplate" TargetType="local:EFGrid"> |
...... |
<Style TargetType="local:EFGrid"> |
...... |
The DeepBlue class is :
[SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores"), ThemeLocation(ThemeLocation.External)] |
public class DeepBlue : Theme |
{ |
public DeepBlue() |
{ |
base.Source = new Uri("/MyAssemblyName;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute); |
} |
} |
When I changed theme to Deepblue, I found that EFRegion and EFGrid didnot load the new style.
StyleManager.ApplicationTheme = ThemeManager.FromName("DeepBlue"); |
What is the correct way to apply theme to custom component?
Please help!
Thanks
fye