I have a .NET5 WPF project. In order to regulate my project, the files follows a specific pattern: There are files end with "View.xaml" which are WPF ContentControls, and files end with "ViewModel.cs" which are INotifyPropertyChanged C# classes. All of them exist in pairs. For the purpose of making the solution explorer more neat, I would like the ViewModel.cs files be nested under their corresponding View.xaml files, as shown in the following screenshot.
This, what I have done already, was acheived by adding the following code to the csproj file:
<ItemGroup>
<Content Include="**\GameWorldViewModel.cs">
<DependentUpon>GameWorldView.xaml</DependentUpon>
</Content>
</ItemGroup>
However, I don't want to respectively write such code for every one of them. I want it to be something like this:
<ItemGroup>
<Content Include="**\*ViewModel.cs">
<DependentUpon>(GetFileNameWithout"ViewModel.cs")View.xaml</DependentUpon>
</Content>
</ItemGroup>
How to do this?