http://blog.csdn.net/taomanman/article/details/6777291
1、新建一个资源文件,比如: Gaugestyle.xaml和MenuButton.xaml
2、在App.xaml中添加该资源:
[csharp]
view plain
copy
- <Application
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- x:Class="spjl1.App">
- <Application.Resources>
- <!-- Resources scoped at the Application level should be defined here. -->
- <ResourceDictionary>
- <ResourceDictionary.MergedDictionaries>
- <ResourceDictionary Source="Gaugestyle.xaml"/>
- <ResourceDictionary Source="MenuButton.xaml"/>
- </ResourceDictionary.MergedDictionaries>
- </ResourceDictionary>
- </Application.Resources>
- </Application>
3、在页面文件后台中使用:
[csharp]
view plain
copy
- ResourceDictionary resources = new ResourceDictionary();
- resources.Source = new Uri("/spjl1;component/MenuButton.xaml", System.UriKind.Relative);
- RadWindow1.Style = resources["ChildWindowStyle1"] as Style;