locked
Difference between RRS feed

  • Question

  • Hi Guys,

    I have a below question in wpf.

    what is the difference between these 2 below namespace and will be included in xaml file when you create ?

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

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

    Thanks

    Vinod

    Thursday, December 25, 2014 1:30 PM

Answers

  • @Vinod,

    MSDN Description of this issue is here:

    http://msdn.microsoft.com/en-us/library/ms747086(v=vs.110).aspx

    See here:

    "Within the namespace declarations in the root tag of many XAML files, you will see that there are typically two XML namespace declarations. The first declaration maps the overall WPF client / framework XAML namespace as the default:

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

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

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

    The relationship between these declarations is that the x: prefix mapping supports the intrinsics that are part of the XAML language definition, and WPF is one implementation that uses XAML as a language and defines a vocabulary of its objects for XAML. Because the WPF vocabulary's usages will be far more common than the XAML intrinsics usages, the WPF vocabulary is mapped as the default.

    The x: prefix convention for mapping the XAML language intrinsics support is followed by project templates, sample code, and the documentation of language features within this SDK. The XAML namespace defines many commonly-used features that are necessary even for basic WPF  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 should have the x:Key attribute set on the element in question. For more information on these and other aspects of XAML see XAML Overview (WPF) or XAML Syntax In Detail. "

    Best regards,



    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 26, 2014 9:43 AM

All replies

  • They're both namespace import and the second also aliases a subset.

    You can't use several fairly important pieces of xaml without the second.

    For example:

    x:Static

    x:Name

    You can see a full list:

    http://msdn.microsoft.com/en-us/library/ms753327(v=vs.110).aspx

    If you don't use any of those then I think you could do without the

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


    Please don't forget to upvote posts which you like and mark those which answer your question.
    My latest Technet article - Dynamic XAML

    Thursday, December 25, 2014 1:44 PM
  • @Vinod,

    MSDN Description of this issue is here:

    http://msdn.microsoft.com/en-us/library/ms747086(v=vs.110).aspx

    See here:

    "Within the namespace declarations in the root tag of many XAML files, you will see that there are typically two XML namespace declarations. The first declaration maps the overall WPF client / framework XAML namespace as the default:

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

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

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

    The relationship between these declarations is that the x: prefix mapping supports the intrinsics that are part of the XAML language definition, and WPF is one implementation that uses XAML as a language and defines a vocabulary of its objects for XAML. Because the WPF vocabulary's usages will be far more common than the XAML intrinsics usages, the WPF vocabulary is mapped as the default.

    The x: prefix convention for mapping the XAML language intrinsics support is followed by project templates, sample code, and the documentation of language features within this SDK. The XAML namespace defines many commonly-used features that are necessary even for basic WPF  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 should have the x:Key attribute set on the element in question. For more information on these and other aspects of XAML see XAML Overview (WPF) or XAML Syntax In Detail. "

    Best regards,



    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 26, 2014 9:43 AM