WPF学习笔记1:XAML之NameSpace

先说点题外话:
写blog的缘由来自于自己学习的过程中诸多痛苦,看了就忘,忘了再看。唉真是人老了,记忆力不行了。
所以突然响了了blog,老做潜水员,这次也借机浮出水面一下。把学的过程中的一些东西记录下啦。

主要教材:
1. MSDN
2. Sams.Windows.Presentation.Foundation.Unleashed.Dec.2006
3. OReilly.Programming.WPF.2nd.Edition.Aug.2007.eBook-BBL

由于没太写过东西,加之时间较为紧张,很多东西直接转载MSDN,或翻译上述2本书。
希望没人骂我太懒就好。

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

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 >


P.S.
在博客园东西写得少,格式还不太会用,大家讲究看看,海涵海涵!

你可能感兴趣的:(namespace)