【发布时间】:2018-11-07 09:10:19
【问题描述】:
我有 WPF 项目,在该项目中,我在整个应用程序的窗口中应用了另一个程序集的样式。但是,我在应用程序内部使用的一个自定义控件没有采用这种样式。它的样式总是从 generic.xaml 加载。
在这个自定义控件类中,我设置了 DefaultStyleKey 属性,并将外部样式文件添加到应用程序资源字典的合并字典中。任何人都可以面对这种问题吗?
注意:其他控件的样式是从另一个组件中应用的
<Window x:Class="WpfApplication_CalenderEdit.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication_CalenderEdit"
xmlns:thirdParty=""
mc:Ignorable="d" thirdParty.Style="ThemeNew"
xmlns:ie="http://schemas.microsoft.com/expression/2010/interactivity"
WindowStartupLocation="CenterScreen"
Title="Calendar Sample" Height="450" Width="625" >
<!--<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>-->
<Grid >
<!--<DockPanel>-->
<StackPanel >
<Calendar WeekNumberForeground="Red" Padding="10" />
<ComboBox Margin="20" Height="35" Width="150"/>
</StackPanel>
【问题讨论】:
-
您是如何“在整个应用程序的窗口中应用另一个程序集的样式”的?对自定义控件执行相同操作。
-
我的主题文件在第三方库中。我将它的程序集包含在我的项目中,并在窗口中全局设置样式