【问题标题】:Adding Dll user control into wpf app.xaml file path shows error将 Dll 用户控件添加到 wpf app.xaml 文件路径显示错误
【发布时间】:2016-01-20 07:36:53
【问题描述】:

我首先创建了一个用户控件 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>

但出现错误,我不知道添加路径的正确语法..请帮助我

【问题讨论】:

    标签: c# wpf xaml dll


    【解决方案1】:

    我过去曾在这种格式上取得过成功。

        <ResourceDictionary Source="/{dllname};component/{folderstructure}/{filename}.xaml" />
    

    dllname 是不带扩展名的 DLL 名称

    【讨论】:

    • 在进行更改时仍然出现错误。请帮助我
    • 根据您的文件夹结构,这应该是&lt;ResourceDictionary Source="/MyStyles;component/Resources/UserControl1.xaml" /&gt; 吗?我提到的文件夹结构是生成 DLL 的项目的文件夹结构,而不是使用 DLL 的项目的文件夹结构
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-05
    • 2017-02-07
    • 2011-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多