RadWindow在使用Implicit Style时不会显示

时间:2017-11-08 20:34:55

标签: wpf telerik

我试图使用隐式样式显示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>

并在主类中显示为

private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    Window1 w = new   Window1();
    w.Show();
}

但是我没有看到它...如果我转向明确的风格它可行......我已经尝试了这个提议,但没有运气,做错了什么?

1 个答案:

答案 0 :(得分:1)

您需要添加对定义了隐式样式的主题程序集的引用,例如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>
相关问题