深入浅出WPF 第一部分(4)
第4章 x名称空间详解
4.2 x名称空间中的Attribute
4.2.1 x:Class
这个attribute的作用是告诉XAML编译器将XAML标签的编译结果与后台代码中指定的类合并。
这个Attribute只能用于根结点,使用x:Class的根节点的类型要与x:Class的值所指示的类型保持一致。x:Class的值所指示的类型在声明时必须使用partial关键字。4.2.2 x:ClassModifier
这个Attribute的作用是告诉XAML编译由标签编译生成的类具有怎样的访问控制级别。
<StackPanel> <TextBox Name="textBox1" Margin="5" x:FieldModifier="public" Text="{DynamicResource ResourceKey=myStr}"/> </StackPanel> <Window.Resources > <sys:String x:Key="myStr" x:Shared="true">Hello, WPF resource!</sys:String> </Window.Resources>