在wpf工程中我们添加一个Window或者UserControl都会建立2个文件, xxx.xaml和xxx.xaml.cs.而且一般cs文件在xaml文件下面。有这样的一个场景,大家都知道这些cs中class都是Partial,我们利用Partial把不同的功能放到不同的cs文件里。
但默认创建的cs文件不会在xaml文件下面。
解决方法很简单:
打开csproj文件, 找到对应的cs文件。 添加DependentUpon节点。
<Compile Include="xxxxx.partial.xaml.cs">
<DependentUpon>xxxxx.xaml</DependentUpon>
</Compile>