[UWP]在UWP项目中使用多个.cs文件?

人气:150 发布:2022-09-22 标签: wpdevelop

问题描述

大家好。对不起,如果我看起来像一个完全的菜鸟,但我几乎是UWP的新手。我了解到MainPage.xaml.cs和App.xaml.cs是使应用程序正常工作的两个文件。我可以在我的项目中添加更多的.cs代码文件,使我的代码看起来更有条理,并且对于一个文件来说,更小吗?

Hello, everyone. Sorry if I look like an utter noob, but I pretty much am new to UWP. I learnt that MainPage.xaml.cs and App.xaml.cs are two files that make the app work. Can I add more .cs code files to my project to make my code seem more organised and less huge for one file?

推荐答案

MainPage.xaml.cs和App.xaml.cs是MainPage.xaml和App.xaml的代码隐藏页面。通常,在创建新页面时会创建此类cs文件。它们逐个对应于xaml文件。

TheMainPage.xaml.cs and App.xaml.cs the code-behind page for MainPage.xaml and App.xaml. Generally such kind of cs files are created when you create a new page. They correspond to the xaml files one by one.

>>我可以向项目中添加更多.cs代码文件,以使我的代码看起来更有条理,对于一个文件来说更小吗?

>>Can I add more .cs code files to my project to make my code seem more organised and less huge for one file?

是的,你也可以在你的项目中直接创建一些.cs文件,用于一些可以在其他地方使用的单独的类。

Yes, you could also create some .cs file directly in your project for some separate classes which could be used in other places.

选择'右键单击项目并选择"添加" - "新项目"类'。

Choose 'Class' when right click the project and select 'Add' -- 'New Item'.

最好的问候,

Roy

149