C# 使用自定义样式创建自定义窗口
我的目标是创建一个窗口,当我使用它时,我可以看到我的风格。我计划将此窗口作为视图的根。因此,我想使用C# 使用自定义样式创建自定义窗口,c#,wpf,resourcedictionary,C#,Wpf,Resourcedictionary,我的目标是创建一个窗口,当我使用它时,我可以看到我的风格。我计划将此窗口作为视图的根。因此,我想使用而不是作为我的根目录。我的visual studio解决方案如下所示: 我计划使用我命名为style.xaml的以下资源字典: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/20
而不是
作为我的根目录。我的visual studio解决方案如下所示:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type TextBlock}" >
<Setter Property="FontFamily" Value="Wingdings 3"/>
</Style>
</ResourceDictionary>
- 注意我必须如何引用:xmlns:my=“clr namespace:ClassLibrary1.Style;assembly=ClassLibrary1”*
this.FontFamily = new System.Windows.Media.FontFamily("Arial Black");
在MyWindow的构造函数中,而不是合并字典
this.FontFamily = new System.Windows.Media.FontFamily("Arial Black");