【6月日新计划06】WPF入門-NameSpace
1. 注釋
1.1 C#注釋
// My comments about the class name could go here...
class Program
{
......
/*
My comments about the class name could go here...
Add as many lines of comments as you want
...and use indentation, if you want to!
*/
class Program
{
......
1.2 xaml注釋
<!-- 注释内容 -->
2. NameSpace
- x:Array 标记扩展
- x:Class Attribute
- x:ClassModifier Attribute
- x:Code 内部XAML类型
- x:FieldModifier Attribute
- x:Key Attribute
- :Name Attribute
- x:Null 标记扩展
- x:Shared Attribute
- x:Property Attribute
- x:Static 标记扩展
- x:Subclass Attribute
- x:Type 标记扩展
- x:TypeArguments Attribute
- x:Uid Attribute
- x:XData 内部XAML类型
<Application
x:Class="Application"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
/Application>
-
xmlns:x="schemas.microsoft.com/winfx/2006/…" 我們聲明一個xaml語言的名稱空間,用來編譯解析xaml,名字映射為x,因為xaml的縮寫就是x,即xaml的名稱空間。
-
xmlns="schemas.microsoft.com/winfx/2006/…" xaml語言允許有一個默認的名稱空間,不用映射名字,所以沒有寫冒號。Presentation這個地址就是告訴編譯器將一系列類庫引入到當前xaml文件中。如果映射了名字,那麼所有標籤就都要映射名字。
2.1 x:Class
這個attribute的作用就是告訴xaml編譯器將xaml標籤的編譯結果與後台代碼中指定的類合併。
2.2 x:ClassModifier
這個attribute的作用就是告訴xaml編譯器有標籤編譯生成的類具有怎樣的訪問權限。
2.3 x:Name
- 為xaml生成的實例創建引用變量
- 檢查實例中是否有name這個屬性,如果有這個屬性,用變量的名字為屬性賦值
3. Code snippets
代碼片段,對重複代碼的快速引用。
Visual Studio → Tool → Code Snippet Manager → Language
4. MVVM
MVVM = Model - View - ViewModel
Model:現實世界中對象的抽象結果 View:UI(視圖) ViewModel:視圖模型