1、项目默认创建之后会有一个本地的命名空间引入
xmlns:local="clr-namespace:studywpf"
2、引入命名空间的格式:
xmlns:前缀="clr-namespace:命名空间"
3、本地使用local 前缀、如果使用系统的则使用 sys前缀。引入示例之后就可以使用命名空间内的类创建对象和控件等等
4、基本引入示例:
<Window x:Class="studywpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sys ="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:studywpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBox VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10,10,13,10"
x:Name="txtQuestion" Grid.Row="0"
TextWrapping="Wrap" FontFamily="Verdana" FontSize="24"></TextBox>
<Button VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,0,0,20"
Width="127" Height="23" x:Name="cmdAnswer" Click="cmdAnswer_Click" Grid.Row="1" Content="Ask thr Eight Ball"></Button>
<TextBox VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10,10,13,10" Name="txtAnswer"
TextWrapping="Wrap" IsReadOnly="True" FontFamily="Verdana" FontSize="24" Foreground="Green"
Grid.Row="2"></TextBox>
<ListBox Grid.Row="2">
<ListBoxItem>
<sys:DateTime>10/11/2013</sys:DateTime>
</ListBoxItem>
<ListBoxItem>
<sys:DateTime>10/11/2013</sys:DateTime>
</ListBoxItem>
</ListBox>
<Grid.Background>
<LinearGradientBrush>
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.00" Color="Red"/>
<GradientStop Offset="0.50" Color="Indigo" />
<GradientStop Offset="1.00" Color="Violet" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Grid.Background>
</Grid>
</Window>
上例中: 引入sys前缀的datetime 命名空间:使用示例为:
<ListBox Grid.Row="2">
<ListBoxItem>
<sys:DateTime>10/11/2013</sys:DateTime>
</ListBoxItem>
<ListBoxItem>
<sys:DateTime>10/11/2013</sys:DateTime>
</ListBoxItem>
</ListBox>
标签:11,10,前缀,示例,空间,命名,WPF,2013 来源: https://blog.csdn.net/qq_31319235/article/details/121611937
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。