我试图使用隐式样式显示RadWindow
,但似乎比预期的要困难得多。为简单起见,我还在这里创建了一个示例项目(您必须添加 Telerik 的程序集才能运行它,您可以在此处下载
我已将我的RadWindow
定义为
<telerik:RadWindow x:Class="LightWeightGrid.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LightWeightGrid"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable="d"
Header="Window1" Height="300" Width="300">
<telerik:RadWindow.Style>
<Style TargetType="telerik:RadWindow" BasedOn="{StaticResource RadWindowStyle}" />
</telerik:RadWindow.Style>
<Grid>
<TextBlock Text="Here I'm"></TextBlock>
并在主类中显示为
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
Window1 w = new Window1();
w.Show();
}
但我看不出来...如果我转向显式样式,它可以工作...我已经尝试过关于SO的建议,但没有运气,做错了什么?
您需要添加对定义隐式样式的主题程序集的引用,例如 Telerik.Windows.Themes.Windows8.dll
,然后将主题资源字典合并到应用程序中,例如在 App.xaml
中:
<Application x:Class="WpfApplication1.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/System.Windows.xaml"/>
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>