Telerik UI 用于 WPF 应用主题。找不到资源
Telerik UI for WPF applying theme. resources not found
我按照 documentation.
中的 NoXaml+将 XAML 文件复制到应用程序的专用文件夹中 方法
我的项目在 InitializeComponent();
行之后立即抛出 System.Windows.Markup.XamlParseException
"Cannot find MediumBrush. the resource name is case sensitive"。包含的 xaml 资源文件确实没有 MediumBrush 密钥。
当我手动添加 <SolidColorBrush x:Key="MediumBrush" Color="Black" />
时,它会抛出 LowBrush、LayoutControlSplitter_Foreground 等。
我引用了以下 dll;
- Telerik.Windows.Controls
- Telerik.Windwos.Controls.Data
- Telerik.Windwos.Controls.Data可视化
- Telerik.Windwos.Controls.Input
- Telerik.Windwos.Controls.Navigation
- Telerik.Windwos.Data
并且,我添加了 xaml 个主题;
- System.Windows.xaml
- Telerik.Windows.Controls.数据.xaml
- Telerik.Windows.Controls.DataVisualization.xaml
- Telerik.Windows.Controls.输入.xaml
- Telerik.Windows.Controls.导航.xaml
- Telerik.Windows.Controls.xaml
当然我注册了xaml资源应用App.xaml文件。
以上xaml个资源文件中没有出现抛出的资源键。这些资源实际上在哪里?
注意:Telerik UI 适用于 .Net 4.5 项目上的 WPF 版本 2017.2.503.45
您还需要添加对实际主题 DLL 的引用,例如 Telerik.Windows.Themes.Office_Black.dll,其中包含 XAML 资源,然后合并所需的XAML 个文件在您的 App.xaml
:
<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>
这是我的错误。我在未定义的 MainWindow.xaml 中使用了 Background={StaticResource MediumBrush}
。
要解决此问题,请定义自己的名为 x:Key="MediumBrush"
的 SolidColorBrush 资源或使用 {telerik:Windows8Resource ResourceKey=MediumBrush}
我按照 documentation.
中的 NoXaml+将 XAML 文件复制到应用程序的专用文件夹中 方法我的项目在 InitializeComponent();
行之后立即抛出 System.Windows.Markup.XamlParseException
"Cannot find MediumBrush. the resource name is case sensitive"。包含的 xaml 资源文件确实没有 MediumBrush 密钥。
当我手动添加 <SolidColorBrush x:Key="MediumBrush" Color="Black" />
时,它会抛出 LowBrush、LayoutControlSplitter_Foreground 等。
我引用了以下 dll;
- Telerik.Windows.Controls
- Telerik.Windwos.Controls.Data
- Telerik.Windwos.Controls.Data可视化
- Telerik.Windwos.Controls.Input
- Telerik.Windwos.Controls.Navigation
- Telerik.Windwos.Data
并且,我添加了 xaml 个主题;
- System.Windows.xaml
- Telerik.Windows.Controls.数据.xaml
- Telerik.Windows.Controls.DataVisualization.xaml
- Telerik.Windows.Controls.输入.xaml
- Telerik.Windows.Controls.导航.xaml
- Telerik.Windows.Controls.xaml
当然我注册了xaml资源应用App.xaml文件。
以上xaml个资源文件中没有出现抛出的资源键。这些资源实际上在哪里?
注意:Telerik UI 适用于 .Net 4.5 项目上的 WPF 版本 2017.2.503.45
您还需要添加对实际主题 DLL 的引用,例如 Telerik.Windows.Themes.Office_Black.dll,其中包含 XAML 资源,然后合并所需的XAML 个文件在您的 App.xaml
:
<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>
这是我的错误。我在未定义的 MainWindow.xaml 中使用了 Background={StaticResource MediumBrush}
。
要解决此问题,请定义自己的名为 x:Key="MediumBrush"
的 SolidColorBrush 资源或使用 {telerik:Windows8Resource ResourceKey=MediumBrush}