将 Dll 用户控件添加到 wpf app.xaml 文件路径中会显示错误
本文关键字:路径 文件 错误 显示 xaml app 用户 Dll 控件 添加 wpf | 更新日期: 2023-09-27 18:31:16
我首先创建一个用户控件dll,并在该dll中编码用于为按钮制作样式。dll 中的代码如下所示
<Style x:Key="myStyle" TargetType="Button">
<Setter Property="Background" Value="Orange" />
<Setter Property="FontStyle" Value="Italic" />
<Setter Property="Padding" Value="8,4" />
<Setter Property="Margin" Value="4" />
</Style>
之后,我将这个引用添加到我的主项目中,作为引用-->添加引用-->浏览-->mystyles.dll
现在我想用这个dll在我的主项目中为按钮制作样式。因此,为此,我在app.xaml中添加了下面显示的代码
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/References;component/Resources/UserControl1.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
但是发生错误,我不知道添加路径的正确语法。请帮助我
我过去在这种格式上取得了成功。
<ResourceDictionary Source="/{dllname};component/{folderstructure}/{filename}.xaml" />
dllname
是不带扩展名的 DLL 的名称