如果您打开包含CardsPage的项目文件,您可以将它们重新链接在一起。
您应该在其中有2个部分,其中一个应该是这样的:
<Page Include="CardsPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="CardsPage.xaml.cs">
<DependentUpon>CardsPage.xaml</DependentUpon>
</Compile>
DependentUpon非常重要,它将使xaml文件在IDE中嵌套在下面。
注意:在您的截图中,CardsPage看起来像是重命名为CardsPage.cs了,我建议您将其重新命名为CardsPage.xaml.cs。
希望这能有所帮助,我不知道除了在项目文件中修改外是否还有其他解决方法。
当我使用XAML重构代码时(例如重命名),我遇到了一些问题,并找到了一个小的扩展程序来“重新链接”文件。
https://marketplace.visualstudio.com/items?itemName=MadsKristensen.FileNesting
这比修改csproj更容易且更安全。
请参见以下示例
步骤2
[
结果
<Compile Include="$(MSBuildThisFileDirectory)MyPage.xaml.cs">
<DependentUpon>MyPage.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)MyPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
<Compile Update="C:\Projects\MyPage.xaml.cs">
<DependentUpon>MyPage.xaml</DependentUpon>
</Compile>