[英]making WPF dll, where to put Application.Resources?
我想将Windows WPF应用程序更改为.dll库。 在Windows App.xaml目录中,我定义了“ Application.Resources”。
<Application x:Class="WpfApplication13.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style TargetType="Control" x:Key="EmptyFocusVisualStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
但是因为在dll库中没有App.xaml文件,现在将这些代码放在哪里? 将新的“资源字典”文件添加到我的“ dll-project”文件中吗? 但这等同于“ Application.Resources”吗?
请寻求帮助或任何示例。 如果您有任何疑问,请询问。
在dll项目中,添加资源字典。
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Control" x:Key="EmptyFocusVisualStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
在使用dll的应用程序的app.xaml中,添加资源字典。 在下面的示例中,资源字典位于MyDll项目中,其路径为MyDllSubFolder / MyResourceDictionary.xaml。
<Application x:Class="WpfApplication13.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/MyDll;component/MyDllSubFolder/MyResourceDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="Control" x:Key="AStyleThatIsInTheAppAndNotTheDll">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.