【问题标题】:Telerik RadWindowTelerik RadWindow
【发布时间】:2015-05-15 11:15:16
【问题描述】:

我在 WPF 中遇到了 Telerik 主题的一些问题 我添加了对 Telerik.Windows.Themes.Windows8 的引用,并使用文件 App.xaml 将资源与以下代码合并:

<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.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/telerik.windows.controls.docking.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

现在我想将 Windows 8 样式应用到我的主窗口,所以我将其更改为 telerik:RadWindow

<telerik:RadWindow
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        x:Class="Foo.MainWindow"
        Header="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBlock HorizontalAlignment="Left" Margin="37,79,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
        <telerik:RadSlider HorizontalAlignment="Left" Margin="273,156,0,0" VerticalAlignment="Top" Width="200"/>
        <telerik:RadButton Content="Button" HorizontalAlignment="Left" Height="Auto" Margin="158,232,0,0" VerticalAlignment="Top" Width="Auto" Click="ButtonBase_OnClick"/>
    </Grid>
</telerik:RadWindow>

在设计器中应用了主题并且看起来一切正常: 但是当我启动应用程序时,它看起来完全不同:

我不知道为什么会发生此错误。 如果我使用代码创建一个 RadWindow,它会完美运行:

RadWindow w = new RadWindow();
w.Width = 500;
w.Height = 500;
w.Show();

【问题讨论】:

    标签: c# wpf telerik


    【解决方案1】:

    我认为当您使用隐式样式时,您需要声明您的窗口样式基于您导入的隐式样式。将此添加到您的 RadWindow XAML 中:

    <telerik:RadWindow.Style>
        <Style TargetType="telerik:RadWindow" BasedOn="{StaticResource RadWindowStyle}" />
    </telerik:RadWindow.Style>
    

    或者将其添加到您的资源字典(local:MainWindow 应解析为 Foo.MainWindow):

    <Style BasedOn="{StaticResource RadWindowStyle}" TargetType="local:MainWindow" />
    

    以下是一些可能有用的链接:

    http://www.telerik.com/forums/show-radwindow-with-implict-style http://www.telerik.com/support/kb/wpf/window/details/how-to-use-radwindow-as-main-window

    【讨论】:

    • 非常感谢。我添加了您的代码并使用 this 教程编辑了 App.xaml 文件,然后它工作了..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-03
    • 1970-01-01
    相关资源
    最近更新 更多