将dll用户控件添加到wpf app.xaml文件路径中显示错误
问题描述:
我首先创建一个usercontrol dll,并在该dll中为编写按钮样式编码。在DLL的代码showned下面将dll用户控件添加到wpf app.xaml文件路径中显示错误
<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中制作样式按钮,我增加showned下面
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/References;component/Resources/UserControl1.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
的代码,但出现错误,我不知道添加路径..Please帮助正确的语法我
答
过去我已经成功使用这种格式。
<ResourceDictionary Source="/{dllname};component/{folderstructure}/{filename}.xaml" />
dllname
是DLL的名称不带扩展
这应该是' '根据您的文件夹结构?我提到的文件夹结构将是生成DLL的项目的文件夹结构,而不是使用DLL的项目的文件夹结构 –
Rhys