简体   繁体   中英

Add a file under a file in Solution Explorer

So in some cases, like when building WPF windows/user-controls and what not certain file types like .xaml and .cs get combined into "one" file (the .cs file is placed underneath the .xaml ).

The problem is that I know this guy that accidentally unbound the two files from each other, and I'm wondering if there is a way to help him put them back together again (or if there is a way to join files like this in general).

In the project file (.csproj) edit it like

<Content Include="Default.js">
    <DependentUpon>Default.aspx</DependentUpon>
</Content>

Eg use the DependentUpon element to nest the file.

See http://davefancher.com/2012/02/23/nesting-files-in-visual-studio/

If you simply want a way to right click on the file in Solution Explorer in Visual Studio and move it under another file there is an easy way to enable this.

  1. Choose the "EXTENSIONS" menu in from Visual Studio.
  2. Click "Manage Extensions"
  3. On the left, choose "Online" -> "Visual Studio Marketplace"
  4. Search for File Nesting
  5. Install the "File Nesting" package from Mads Kristensen
  6. Restart Visual Studio.

Now you can select a group of files in Visual Studio Solution Explorer, right click on them, and "File Nesting" is an option on the menu. It will also enable "auto-nesting" for particular types of files.

I am not associated with Mads but their solution worked will for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM