【问题标题】:Telerik UI for WPF applying theme. resources not found用于 WPF 应用主题的 Telerik UI。找不到资源
【发布时间】:2017-06-26 18:26:05
【问题描述】:

我按照documentation 中的 NoXaml+将 XAML 文件复制到应用程序的专用文件夹中方法。

我的项目在InitializeComponent(); 行之后抛出System.Windows.Markup.XamlParseException“找不到MediumBrush。资源名称区分大小写”。包含的 xaml 资源文件确实没有 MediumBrush 键。

当我手动添加<SolidColorBrush x:Key="MediumBrush" Color="Black" /> 时,它会抛出 LowBrush、LayoutControlSplitter_Foreground 等。

我引用的dll如下;

  • Telerik.Windows.Controls
  • Telerik.Windwos.Controls.Data
  • Telerik.Windwos.Controls.DataVisualization
  • Telerik.Windwos.Controls.Input
  • Telerik.Windwos.Controls.Navigation
  • Telerik.Windwos.Data

而且,我添加了 xaml 主题;

  • System.Windows.xaml
  • Telerik.Windows.Controls.Data.xaml
  • Telerik.Windows.Controls.DataVisualization.xaml
  • Telerik.Windows.Controls.Input.xaml
  • Telerik.Windows.Controls.Navigation.xaml
  • Telerik.Windows.Controls.xaml

当然我注册了xaml资源app App.xaml文件。

上面的 xaml 资源文件中没有出现抛出的资源键。这些资源实际上在哪里?

注意:.Net 4.5 项目上 WPF 版本 2017.2.503.45 的 Telerik UI

【问题讨论】:

    标签: c# wpf xaml telerik themes


    【解决方案1】:

    您还需要添加对包含 XAML 资源的实际主题 DLL 的引用,例如 Telerik.Windows.Themes.Office_Black.dll,然后将所需的 XAML 文件合并到您的 @ 987654323@:

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/System.Windows.xaml"/>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.xaml"/>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.GridView.xaml"/>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.Data.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
    

    【讨论】:

    【解决方案2】:

    这是我的错。我在未定义的 MainWindow.xaml 中使用了Background={StaticResource MediumBrush}

    要解决此问题,请定义名为 x:Key="MediumBrush" 的自己的 SolidColorBrush 资源或使用 {telerik:Windows8Resource ResourceKey=MediumBrush}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-04
      • 2018-01-23
      相关资源
      最近更新 更多