制作 WPF dll,将 Application.Resources 放在哪里?
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" 新 "Resource Dictionary" 文件?但这等同于 "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>
我想将 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" 新 "Resource Dictionary" 文件?但这等同于 "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>