在wpf SharedProject中使用DesignTimeResources

嗨,我想要设计时可用的资源

在一个简单的项目中,我可以在项目属性文件夹中创建一个DesignTimeResources.xaml(这是一个资源字典)文件

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,/mylibrary;component/Themes/Basic/Colors.xaml"  />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

并将project.csproj修改为:

<Page Include="Properties\DesignTimeResources.xaml" Condition="'$(DesignTime)'=='true' OR ('$(SolutionPath)'!='' AND Exists('$(SolutionPath)') AND '$(BuildingInsideVisualStudio)'!='true' AND '$(BuildingInsideExpressionBlend)'!='true')">
  <Generator>MSBuild:Compile</Generator>
  <SubType>Designer</SubType>
  <ContainsDesignTimeResources>true</ContainsDesignTimeResources>
</Page>

现在我可以在设计时访问所有资源。

但是我需要在SharedProject中使用此方法,这就是我的项目的结构

mylibrary_shared

mylibraryDemo_shared(包含用户界面)

mylibraryNET45(在此处共享mylibrary_shared)

mylibraryDemoNET45(mylibraryNET45和mylibraryDemo_shared在这里引用)

dongyingyifeng 回答:在wpf SharedProject中使用DesignTimeResources

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3149951.html

大家都在问