0

我已经阅读了一堆关于资源字典的帖子,但在我的情况下没有一个有效。我的解决方案仅由 Delphi (VCL) 应用程序使用的 dll 构成。这些 dll,有 windows (WPF) 窗体,等等。

我在哪里可以放一些资源字典,这样所有的 dll 都可以重用?

4

2 回答 2

0

Not sure what you mean by "resources" exactly, but you can add files into a .dll by including them in your project (just create a new folder "resources", then right click and add existing item to it).

Right click and select properties on the file you just added. Under Build Action, select Embedded Resource. When you compile your project now, the file will be included within the .dll.

I'm sure you can find lots of info about accessing embedded resources; see this SO post, for instance, about reading from an embedded text file.

于 2013-10-03T12:33:52.563 回答
0

我得到这个工作,按照以下步骤:

  1. 我创建了一个新的 dll 项目,并在其中添加了新项目“Resource Dictionay (WPF)”。在这个文件中,我声明了我的自定义资源,如下所示:

    <Style TargetType="Button">
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" Value="0.30"></Setter>
            </Trigger>
            <Trigger Property="IsEnabled" Value="True">
                <Setter Property="Opacity" Value="1"></Setter>
            </Trigger>
        </Style.Triggers>
        <Setter Property="Background" Value="Transparent"></Setter>
        <Setter Property="BorderBrush" Value="Transparent"></Setter>
    </Style>
    

  2. 在我的其他项目中,我在 XAML 中以这种方式引用此资源:

    <Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/my.project.here;component/Assets/CommonDictionary.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    

  3. 而已。

于 2013-10-04T14:52:29.157 回答