Move code file under another file in project

被刻印的时光 ゝ 提交于 2020-01-24 22:25:06

问题


I want to move one code file under the group of another, related file, like here:

As you see, SingleObjectViewModel.Commands.cs is hidden in SingleObjectViewModel.cs group. It can be useful in some cases.

I've created SingleDocumentViewModel.Commands.cs but simple drag-n-drop in Visual Studio do not work.

How to achieve it?


回答1:


I found one way of doing this, but it is not user-friendly and needs to edit project file by hands. I'm not sure it will work in other versions of Visual Studio then mine (MS Visual Studio 2013)

First, unload project (right-click on project, Unload Project).

Then edit csproj file (right-click again, Edit *.csproj)

In editor, replace:

<Compile Include="SingleDocumentViewModel.Commands.cs">

with

<Compile Include="SingleDocumentViewModel.Commands.cs">
  <DependentUpon>SingleDocumentViewModel.cs</DependentUpon>
</Compile>

Then save edited file and load project again (right-click on it, Reload project).

Now files are grouped:



来源:https://stackoverflow.com/questions/27397824/move-code-file-under-another-file-in-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!