Rus*_*den 5 xaml templates visual-studio
无论模板的设置如何,Visual Studio(2019 - 尚未在其他版本上测试)似乎都在强制从 Visual Studio 项模板添加的任何 .xaml 文件将其构建操作设置为 Page。例如:
<TemplateContent>
<References />
<ProjectItem ReplaceParameters="true" ItemType="EmbeddedResource" CustomTool="" TargetFileName="$fileinputname$.xaml">Page1.xaml</ProjectItem>
<ProjectItem ReplaceParameters="true" ItemType="EmbeddedResource" CustomTool="" TargetFileName="$fileinputname$.cs">Page1.xaml</ProjectItem>
</TemplateContent>
Run Code Online (Sandbox Code Playgroud)
这只是两次添加相同的 XAML 文件,以证明当作为 .cs 文件添加时,一切都按预期工作,构建操作对应于所需的 ItemType。但是,当使用 .xaml 扩展名添加时,构建类型会强制为 Page - 覆盖 ItemType 规范。
这是 Visual Studio 项模板解析器的预期行为,如果是,有什么方法可以覆盖它吗?我所需要的只是将 XAML 文件正确地视为 XAML 文件(以启用设计器),并将其构建操作设置为嵌入式资源。