【问题标题】:Telerik set application theme from XAMLTelerik 从 XAML 设置应用程序主题
【发布时间】:2012-03-25 20:09:26
【问题描述】:

是否可以在 Telerik 中从 XAML 设置应用程序范围的主题?只有一个代码隐藏示例。我想在 XAML 中设置,并在设计模式下也有一个 Metro 主题。

【问题讨论】:

    标签: silverlight xaml telerik


    【解决方案1】:

    您可以通过以下方式实现:

    <Application
        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"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     
        mc:Ignorable="d"
        x:Class="SilverlightApplication.App">
            <Application.Resources>
                <telerik:MetroTheme x:Key="Theme" IsApplicationTheme="True"/>
            </Application.Resources>
     </Application>
    

    【讨论】:

    • 谢谢!我缺少 IsApplicationTheme 属性。
    【解决方案2】:

    起初这对我不起作用。它抛出了以下异常:

    {System.Collections.Generic.KeyNotFoundException: 给定的密钥是 字典中没有。在 System.Collections.Generic.Dictionary`2.get_Item(TKey key) at System.Windows.ResourceManagerWrapper.GetResourceForUri(Uri xamlUri, 类型组件类型)}

    设置属性“Telerik.Windows.Controls.Theme.ApplicationThemeSetter” 抛出异常。 [行:53 位置:70]

    我尝试在 App.xaml 和 Generic.xaml 中声明它,但结果相同。

    我还尝试在 XAML 中设置主题,例如:

    <t:RadGridView t:StyleManager.Theme="Windows8Theme" ..../>
    

    但这没有影响。

    注意:我使用的是 2012 年第三季度

    我最终解决了这个问题。您必须包含主题 DLL。因此,在我想使用 Windows8Theme 的情况下,我需要添加对 Telerik.Windows.Themes.Windows8.dll 的引用。如果 Telerik 的代码抛出一个异常说的话会很有帮助,但是“嘿”,这只是我。

    • 拉沙德

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-25
    • 1970-01-01
    相关资源
    最近更新 更多