2016-08-16 60 views

回答

0

术语“背后的代码”只介绍了人类的概念。 .xaml和.xaml.cs只属于彼此,因为它们包含编译到一个类中的部分类。因为有在.csproj的DependentUpon标签.xaml.cs文件显示为在Visual Studio他们的.xaml文件的一个孩子。一些例子:

<ItemGroup> 
    <Compile Include="SomeClass.xaml.cs"> 
    <DependentUpon>SomeClass.xaml</DependentUpon> 
    </Compile> 
</ItemGroup> 
<ItemGroup> 
    <Page Include="SomeClass.xaml"> 
    <SubType>Designer</SubType> 
    <Generator>MSBuild:Compile</Generator> 
    </Page> 
</ItemGroup> 

这就是它在这个例子中如何实现的。

+0

我可以在他们在添加.csprog文件中看到,这样解释了一些,但我将如何在项目MainPage.xaml中下添加一个新的CS文件。对不起,我们的老狗不会得到这个新的东西 – MobileDeveloper

+0

只需将一个普通的.cs文件添加到项目中即可。然后卸载项目,在文本编辑器中打开它,并将DependentUpon标记添加到新创建文件的项目中。 –