我可以在 Visual Studio 中创建一个位于 .Designer.cs 文件旁边的文件吗? [英] Can I create a file that sits next to a .Designer.cs file in Visual Studio?

查看:20
本文介绍了我可以在 Visual Studio 中创建一个位于 .Designer.cs 文件旁边的文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 中,当您在解决方案中创建新的 Windows 窗体时会创建两个文件(例如,如果您创建 MyForm.cs,还会创建 MyForm.Designer.cs 和 MyForm.resx).后两个文件在解决方案资源管理器中显示为子树.

In Visual Studio, two files are created when you create a new Windows Form in your solution (e.g. if you create MyForm.cs, MyForm.Designer.cs and MyForm.resx are also created). These second two files are displayed as a subtree in the Solution Explorer.

有没有办法将文件添加到 Windows 窗体类的子树或组中?

推荐答案

在编辑模式下打开 .csproj,在另一个文件下寻找你想要的文件,并添加 DependentUpon 元素,如下所示:

Open .csproj in edit mode, look for the file you want to be under another one, and add the DependentUpon element, like this:

<Compile Include="AlertDialog.xaml.cs">
  <DependentUpon>AlertDialog.xaml</DependentUpon>
</Compile>

这篇关于我可以在 Visual Studio 中创建一个位于 .Designer.cs 文件旁边的文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆