问题
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