:: Home

  login:         
  passwords:  

WPF FAQs

WPF General Questions
Concepts Element Tree
Concepts Dependency Property
Concepts Attached Property
Concepts Routed Events
Concepts Resources.
Concepts Animation
Concepts Freezable Object
Concepts Input and Commands.
Concepts Layouts
XAML Inline Styles and Templates
XAML XML Namespaces
XAML Code Behind
XAML Custom Class
XAML Type Converters
Content Model ItemControl
Content Model HeaderedItemsControl
Content Model HeaderedContentControl
Content Model Content Control
Content Model Decorator Content Model
Content Model Panel Content Model
Documents Serialization and Storage
Documents Annotations
Documents Flow Content
Documents Printing
Graphics and Multimedia Rendering Graphics
Graphics and Multimedia Animation and Timing
Graphics and Multimedia 2D Graphics
Graphics and Multimedia 3D Graphics
Graphics and Multimedia Visual Layer
Control Customization Adorners
Control Customization Stylable controls
Control Customization ControlTemplates
Data Data Binding
Data DragandDrop
Data Serialization
Globalization and Localization Attributes
Globalization and Localization Comments
Globalization and Localization Globalization Struc
Application and Deployment ClickOnce
Application and Deployment Frame
Application and Deployment Page
Application and Deployment Navigation
Application and Deployment Setup
Application and Deployment Window
Interoperability Message Loops Between
Interoperability Win32 in WPF
Interoperability WPF in Win32
Interoperability Windows Forms and WPF
Security Trusted Security
Security Partial Trust Security
Tools Microsoft Expression Blend
Tools ZAM3D
Tools XAMLPAD
Controls ToolTip
Controls TextBlock
Controls TabControl
Controls ProgressBar
Controls PrintDialog
Controls Popup
Controls TextBox
Controls Canvas
Controls ComboBox
Controls ListBox
Controls StatusBar
Controls ToolBar
Controls Context Menu
Controls Expander
Controls DocumentViewer
Controls FlowDocumentReader
Controls GroupBox
Controls GridSplitter
Controls Image
Controls Menu
Controls ScrollBar
Controls Slider
Controls RichTextBox
Controls Border
Controls Buttons

SilverLight Interview Qs

SAP Interview Questions

Oracle Interview Questions

PHP Interview Questions

Ajax Interview Questions

IIS 7.0

OOP Interview Questions

Ruby Interview Questions

Sql Server Interview Questions

Winforms Interview Questions

SharePoint 2007 Questions

Microsoft Crm Questions

XAML XML Namespaces Interview Questions & FAQs

Questions and answers for XAML XML Namespaces.

12. XAML XML Namespaces

    12.1 How can I map CLR Namespaces to XML Namespaces in an Assembly ?
    12.2 Which namespace is used to associate namespace identifiers with element names ? Is there any effect on the attributes ?

12.1 How can I map CLR Namespaces to XML Namespaces in an Assembly ?

WPF defines a CLR attribute that is consumed by XAML processors in order to map multiple CLR namespaces to a single XML namespace. The "xlmns" Definition Attribute is placed at the assembly level in the source code that produces the assembly. The WPF assembly source code uses this attribute to map the various common namespaces such as System.Windows and System.Windows.Controls to the http://schemas.microsoft.com/winfx/2006/xaml/presentation namespace. WPF defines a CLR attribute that is consumed by XAML processors in order to map multiple CLR namespaces to a single XML namespace. The "xlmns" Definition Attribute is placed at the assembly level in the source code that produces the assembly. The WPF assembly source code uses this attribute to map the various common namespaces such as System.Windows and System.Windows.Controls to the http://schemas.microsoft.com/winfx/2006/xaml/presentation namespace.

The 'xmlns' Definition Attribute takes two parameters: the XML namespace name and the CLR namespace name. More than one 'xmlns' Definition Attribute can exist to map multiple CLR namespaces to the same XML namespace. Once mapped, members of those namespaces can also be referenced without full qualification if desired, by providing the appropriate using statement in the partial-class code-behind page. For more details, see 'xmlns Definition Attribute'.

12.2 Which namespace is used to associate namespace identifiers with element names ? Is there any effect on the attributes ?

There is one more type of namespace declaration that can be used to associate namespace identifiers with element names. This is known as a default namespace declaration which uses the following syntax. xmlns=''

Notice that there is no prefix. When a default namespace declaration is used on an element, all unqualified element names within it's scope are automatically associated with the specified namespace identifier.

Default namespace declarations, however, have absolutely no effect on attributes. The only way to associate an attribute with a namespace identifier is through a prefix.

Consider the following example.

[XAML]

<d:student xmlns:d='http://www.develop.com/student'

xmlns='urn:foo' id='3235329'

> 

<name>Jeff Smith</name>

<language xmlns=''>C#</language>

<rating>35</rating>

</d:student>

Here, "student" is from the http://www.develop.com/student namespace while "name" and "rating" are from the default namespace urn:foo. The 'id' attribute doesn't belong to a namespace since attributes aren't automatically associated with the default namespace identifier.

Notice that there is no prefix. When a default namespace declaration is used on an element, all unqualified element names within it's scope are automatically associated with the specified namespace identifier.

The syntax for default namespaces was designed for convenience but they tend to cause more confusion than their worth. The confusion typically stems from the fact that elements and attributes are treated differently and it's not immediately apparent that nested elements are being assigned the default namespace identifier. Nevertheless, in the end, choosing between prefixes and default namespaces is mostly a matter of style, except when attributes come into play.

bottom user control
::  Home :: Services ::  Prices ::  Request Quote
Copyright 2007, Megasolutions Ltd