使用隐式样式时 RadWindow 不显示
RadWindow doesn't show when using Implicit Style
我正在尝试使用隐式样式显示 RadWindow
,但它似乎比预期的要难得多。为简单起见,我还在这里创建了一个示例项目(您必须添加 Telerik 的程序集才能 运行 它,您可以下载它 here
我已将 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>
并在主要class中显示为
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
Window1 w = new Window1();
w.Show();
}
但我没看到它...如果我转向 Explicit 样式它会起作用...我已经在 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>
我正在尝试使用隐式样式显示 RadWindow
,但它似乎比预期的要难得多。为简单起见,我还在这里创建了一个示例项目(您必须添加 Telerik 的程序集才能 运行 它,您可以下载它 here
我已将 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>
并在主要class中显示为
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
Window1 w = new Window1();
w.Show();
}
但我没看到它...如果我转向 Explicit 样式它会起作用...我已经在 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>