Telerik从XAML设置应用程序主题

时间:2012-03-08 10:19:23

标签: silverlight xaml telerik

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

2 个答案:

答案 0 :(得分:7)

您可以按如下方式实现此目的:

<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>

答案 1 :(得分:2)

起初这对我不起作用。它抛出了以下几个例外:

  

{System.Collections.Generic.KeyNotFoundException:给定的密钥是   不在字典中。在   System.Collections.Generic.Dictionary`2.get_Item(TKey key)at   System.Windows.ResourceManagerWrapper.GetResourceForUri(Uri xamlUri,   输入componentType)}

     

设置属性'Telerik.Windows.Controls.Theme.ApplicationThemeSetter'   抛出一个例外。 [行:53位置:70]

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

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

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

但这没有任何影响。

注意:我正在使用2012年的Q3

我最终解决了这个问题。您必须包含主题DLL。所以在我的情况下我想使用Windows8Theme,我需要添加对 Telerik.Windows.Themes.Windows8.dll 的引用。如果Telerik的代码抛出一个例外,那么会有所帮助,但是“嘿”,那就是我。

  • 拉沙德
相关问题