WPF学习笔记1:XAML之NameSpace

35 篇文章 1 订阅

http://www.cnblogs.com/jacksonyin/archive/2008/02/25/1080336.html

=========================================================================


WPF程序集中使用多个XmlnsDefinitionAttribute的一个硬编码
NameSpace 定义支持向下嵌套

----------------------------------------------------------------------------------------------xmlns="http://schemas.microsoft.com/winfx/2006/xaml"
对应的.NET的命名空间:
System.Windows.Markup

映射单独的可扩展应用程序标记语言 (XAML) 命名空间,通常将其映射为x:前缀。
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

----------------------------------------------------------------------------------------------
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
将整个 Windows Presentation Foundation (WPF) 命名空间映射为默认命名空间:

对应的.NET的命名空间:
. System.Windows
. System.Windows.Automation
. System.Windows.Controls
. System.Windows.Controls.Primitives
. System.Windows.Data
. System.Windows.Documents
. System.Windows.Forms.Integration
. System.Windows.Ink
. System.Windows.Input
. System.Windows.Media
. System.Windows.Media.Animation
. System.Windows.Media.Effects
. System.Windows.Media.Imaging
. System.Windows.Media.Media3D
. System.Windows.Media.TextFormatting
. System.Windows.Navigation
. System.Windows.Shapes

----------------------------------------------------------------------------------------------
自定义增加NameSpace:
xmlns:custom="clr-namespace:SDKSample;assembly=SDKSampleLibrary"

Sample:

< my:WindowsFormsHost Height = " 100 "  Name = " windowsFormsHost1 "  xmlns:my = " clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration "   />

< Window x:Class = " WpfApplication7.Window1 "
xmlns
= " http://schemas.microsoft.com/winfx/2006/xaml/presentation "
xmlns:x
= " http://schemas.microsoft.com/winfx/2006/xaml "
Title
= " Window1 "  Height = " 300 "  Width = " 300 "   >

----------------------------------------------------------------------------------------------
使用NameSpaceSample

1.  全局

< Window x:Class = " NonRectangularWindowSample.Window1 "
xmlns
= " http://schemas.microsoft.com/winfx/2006/xaml/presentation "
xmlns:x
= " http://schemas.microsoft.com/winfx/2006/xaml "
>
    
< Grid >
        
< Button  > Button </ Button >
    
</ Grid >
</ Window >

 2. 独立使用

< Button xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation " >
Button
</ Button >

3. 使用前缀

< y:Window
x:Class
= " NonRectangularWindowSample.Window1 "
xmlns:y
= " http://schemas.microsoft.com/winfx/2006/xaml/presentation "
xmlns:x
= " http://schemas.microsoft.com/winfx/2006/xaml "
Title
= " Window1 "  Height = " 300 "  Width = " 300 " >
    
< y:Grid >
        
< y:Button > Button </ y:Button >
    
</ y:Grid >
</ y:Window >
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值