【问题标题】:Is it possible to override one part of a control template in a Telerik WPF theme?是否可以在 Telerik WPF 主题中覆盖控件模板的一部分?
【发布时间】:2017-01-13 21:35:28
【问题描述】:

我在我的 WPF 应用程序中使用 Telerik Windows 8 主题。但是,我不喜欢使用彩色方块而不是 Windows 7 主题中的实际复选标记来指示复选框选中状态的方式。复制复选框模板并对其进行修改以使用 Windows 7 主题复选框模板中的复选框复选标记非常简单。

但是,我无法找到将包含此修改模板的样式添加到我的 Application.Resources 的方法,以便将其应用于我的应用程序中的所有复选框。出于某种原因,Telerik Windows 8 主题中的模板仍然是应用的模板。

我尝试了几种不同的方法,但似乎没有任何效果。我的最新方法是将以下样式添加到我的 Application.Resources 资源字典中:

<Style BasedOn="{StaticResource {telerik:ThemeResourceKey ThemeType=telerik:Windows8Theme, ElementType=CheckBox}}" TargetType="CheckBox" >     <Setter Property="Template">     ....     </Setter> </Style>

有人知道这个问题的答案吗?我正在尝试做的事情可能吗?

谢谢, 克雷格

【问题讨论】:

标签: c# wpf checkbox telerik themes


【解决方案1】:
  1. 确保从 Telerik 安装的 NoXaml 文件夹中引用 DLL
  2. 不要添加对任何主题 DLL 的任何引用
  3. 在 Telerik WPF 安装位置,进入 Themes.Implicit > WPF40 > Windows8 > Themes
  4. 将 .xaml 文件从那里放入您的解决方案中
  5. 在您的 App.xaml 资源字典中引用它们:

    <Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Themes/Office2016/System.Windows.xaml" />
            <ResourceDictionary Source="Themes/Office2016/Telerik.Windows.Controls.xaml" />
            <ResourceDictionary Source="Themes/Office2016/Telerik.Windows.Controls.GridView.xaml" />
     etc...
            </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    

  6. 现在您可以进入 System.Windows.xaml 文件,找到复选框的样式并编辑样式以将正方形更改为勾号 (我认为是需要更改的复选框模板中名为 CheckVisual 的 Rectangle)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-11
    • 1970-01-01
    • 2016-07-02
    相关资源
    最近更新 更多