【发布时间】:2019-12-19 13:11:12
【问题描述】:
我目前正在将我的项目转换为 Visual Studio 的新 SDK 格式。不幸的是,我无法让设计师工作。过去,我在每个项目中添加了一个 app.xaml,其中包含所有与设计时相关的资源。这会导致一些警告,但 Visual Studio 给了我我需要的东西:XAML 设计器中的语法完成
切换到 SDK 格式后出现错误:\Microsoft.WinFX.targets(225,9): error MC1002: Library project file cannot specify ApplicationDefinition element.
因此我删除了 app.xaml 文件,但现在我没有语法完成功能,并且设计器不再显示我的控件。
我尝试的是添加资源文件并设置
<Page Include="Properties\DesignTimeResources.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<ContainsDesignTimeResources>true</ContainsDesignTimeResources>
</Page>
在 csproj 文件中。但是这个技巧不再起作用了,因为页面不能再在 csproj 文件中定义了..
Microsoft 认为这应该如何工作?有什么方法可以在不编辑我的 1000 个 xaml 文件的情况下将设计时资源添加到我的项目中?
我真的想避免将此添加到我的每个 xaml 文件中:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MyAssembly;component/Resources/ResourceBundle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
【问题讨论】:
-
有一个 GitHub thread 有同样的问题
-
设计师本身不是问题。问题是设计时资源..