WPF controls not recognized in code-behind when using new CSPROJ format
A slight improvement on your previous answer is to include the .g.cs files, but mark them as not visible so they do not show in the solution. You will then also need to mark the BaseIntermediateOutputPath as not visible otherwise it shows up as an empty folder.
This gives the same behaviour but looks tidier as you're not seeing the obj folder in the solution explorer.
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" Exclude="App.xaml" />
<Compile Update="**\*.xaml.cs" SubType="Designer" DependentUpon="%(Filename)" />
<Compile Include="$(IntermediateOutputPath)*.g.cs" Visible="false" />
<None Include="$(BaseIntermediateOutputPath)" Visible="false" />
</ItemGroup>