<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:UC="clr-namespace:WpfApplication1"
xmlns:UC1="clr-namespace:WpfControlLibrary1;assembly=WpfControlLibrary1"
Title="Window1" Height="300" Width="300">
<!--
x:Class="WpfApplication1.Window1" 与后台对应 public partial class Window1 : Window
-->
<!--
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
默认命名空间的控件不用使用前缀
-->
<StackPanel x:Name="stackpanel">
<!--
xmlns:UC="clr-namespace:WpfApplication1"命名空间
本程序集
-->
<UC:UserControl1></UC:UserControl1>
<!--
xmlns:UC="clr-namespace:WpfControlLibrary1;assembly=WpfControlLibrary1" 命名空间;程序集
引用程序集
-->
<UC1:UserControl1></UC1:UserControl1>
</StackPanel >
</Window>
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:UC="clr-namespace:WpfApplication1"
xmlns:UC1="clr-namespace:WpfControlLibrary1;assembly=WpfControlLibrary1"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<sys:String x:Key="name">TEST</sys:String>
<!--
x:Type 将模板或者样式指定在哪一种对象上时需要用type指定。
-->
<Style TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="Red"/>
</Style>
<x:ArrayExtension x:Key="arr" Type="{x:Type sys:Int32}">
<sys:Int32>1</sys:Int32>
<sys:Int32>2</sys:Int32>
<sys:Int32>3</sys:Int32>
</x:ArrayExtension>
</Window.Resources>
<StackPanel x:Name="stackpanel">
<!--
StaticResource用于获取资源的值,值获取在xaml编译的时候完成 xaml里的全局变量
-->
<TextBlock Text="{StaticResource ResourceKey=name}"></TextBlock>
<!--
DynamicResource跟StaticResource唯一不同的是,它是在运行时获取的
-->
<TextBlock Text="{DynamicResource ResourceKey=name}"></TextBlock>
<!--
Binding
-->
<TextBox Height="23" Name="textBox1" Width="120" />
<TextBox Height="23" Name="textBox2" Width="120"
Text="{Binding ElementName=textBox1, Path=Text}" />
<!--
x:Static 主要用于在xaml中获取某个对象的静态值,上代码说话。
后台 public static string name = "staticTest";
-->
<TextBox Height="23" Text="{x:Static UC:Window1.name}"
Name="textBox3" Width="120" />
<!--
x:null这个就比较简单了,xaml中某某控件设为null就靠它了。
-->
<TextBox Height="23" Text="{x:Null}"
Name="textBox4" Width="120" />
<!--
x:Array 这个主要就是在xaml中创建数组,还是举个例子。
-->
<ListBox ItemsSource="{StaticResource ResourceKey=arr}"></ListBox>
</StackPanel >
</Window>