例如,下面的代码到指定的命名空间。不仅导入的命名空间,并且还为指定的命名空间前缀local。当然,你也可以指定一个前缀为另一个名称,这可以定义。导入后,市民可以在命名当前空间XAML使用代码。例如,在演示样品TimeButton这个类,事实上,它是从继承button控件类。
<Window x:Class="Demo002.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Demo002"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="Grid1">
<Grid x:Name="Grid2">
<Grid x:Name="Grid3">
<StackPanel x:Name="StackPanel1">
<ListBox x:Name="ListBox1" />
<local:TimeButton x:Name="TimeButton1" Width="80" Height="80"
Content="Report Time" />
</StackPanel>
</Grid>
</Grid>
</Grid>
</Window>
版权声明:本文博主原创文章,博客,未经同意不得转载。