Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

xmlns xmlns:x in App.xaml RSS

3 replies

Last post Jun 21, 2009 03:03 PM by clint1222

(0)
  • nirlevin

    nirlevin

    Member

    40 Points

    136 Posts

    xmlns xmlns:x in App.xaml

    Jun 18, 2009 05:34 AM | LINK

    App.xaml:

    What are the meaning of xmlns xmlns:x?

    What is the differnce between  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    and xmlns="http://schemas.microsoft.com/client/2007"?

    Which is the correct one?

    Is xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" correct? Is there newer\better?

  • pbrooks

    pbrooks

    Contributor

    2715 Points

    362 Posts

    Re: xmlns xmlns:x in App.xaml

    Jun 18, 2009 04:44 PM | LINK

    Directly quoted from the MSDN documentation:

    Within the root element of many XAML files, there are two xmlns declarations. The first declaration maps the overall Silverlight XAML namespace as the default:

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

    Note that this is the same XAML namespace that WPF uses as its default.

    The second declaration maps a separate XML namespace for XAML, mapping it (typically) to the x: prefix:

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    The relationship between these declarations is that XAML is a language definition, and Silverlight is one implementation that uses XAML as a language. Silverlight in particular uses a strict subset of XAML. The XAML language specifies certain language elements, and each of these should be accessible through XAML processor implementations working against the XAML namespace. Silverlight also uses a subset of the set of elements that are in WPF.

    The Silverlight implementation of XAML and its intended programming model generally uses the default XML namespace for its own XAML vocabulary and uses a separate mapped prefix for the markup syntax expected in the Silverlight subset of the XAML namespace. By convention that prefix is x:, and this same x: convention is followed by project templates, sample code, and the documentation of language features within this documentation set. The XAML namespace defines several commonly used features that are necessary even for basic Silverlight-based applications. For instance, in order to join any code-behind to a XAML file through a partial class, you must name that class as the x:Class attribute in the root element of the relevant XAML file. Or, any element as defined in a XAML page that you wish to access as a keyed resource in a ResourceDictionary must have the x:Key attribute set on the object element in question. 

     

    If this has answered your question, please click on "Mark as Answer" on this post.

    Thanks,
    Page Brooks
    PageBrooks.com | @pbrooks
  • nirlevin

    nirlevin

    Member

    40 Points

    136 Posts

    Re: xmlns xmlns:x in App.xaml

    Jun 21, 2009 05:52 AM | LINK

    What is the differnce between xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" and xmlns="http://schemas.microsoft.com/client/2007"?
  • clint1222

    clint1222

    Contributor

    2066 Points

    299 Posts

    Re: xmlns xmlns:x in App.xaml

    Jun 21, 2009 03:03 PM | LINK

    Hi,

     The note near the bottom of this msdn page should answer your question.

    http://msdn.microsoft.com/en-us/library/cc189036(VS.95).aspx

     

    NoteNote:

    In the Silverlight version 1.0 era, the default XAML namespace used in templates for XAML was http://schemas.microsoft.com/client/2007. That namespace still has legacy support, but using http://schemas.microsoft.com/winfx/2006/xaml/presentation as the default namespace URI is strongly recommended for any current Silverlight XAML. This is for migration and tooling reasons: the http://schemas.microsoft.com/winfx/2006/xaml/presentation namespace is shared with WPF, and some tools may not account for the http://schemas.microsoft.com/client/2007 namespace.