Click here to Skip to main content
15,897,371 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF namespaces reference Pin
Ian Shlasko27-Apr-11 7:20
Ian Shlasko27-Apr-11 7:20 
GeneralRe: WPF namespaces reference Pin
SledgeHammer0127-Apr-11 7:46
SledgeHammer0127-Apr-11 7:46 
GeneralRe: WPF namespaces reference Pin
Pete O'Hanlon27-Apr-11 8:51
mvePete O'Hanlon27-Apr-11 8:51 
GeneralRe: WPF namespaces reference Pin
Pete O'Hanlon27-Apr-11 7:19
mvePete O'Hanlon27-Apr-11 7:19 
GeneralRe: WPF namespaces reference Pin
devvvy27-Apr-11 21:20
devvvy27-Apr-11 21:20 
GeneralRe: WPF namespaces reference Pin
Pete O'Hanlon27-Apr-11 22:16
mvePete O'Hanlon27-Apr-11 22:16 
GeneralRe: WPF namespaces reference Pin
RugbyLeague27-Apr-11 22:31
RugbyLeague27-Apr-11 22:31 
GeneralAnswers here! Thanks [modified] Pin
devvvy27-Apr-11 21:06
devvvy27-Apr-11 21:06 
Hi guys,

I think I have the answers - collected from couple places posting here to share with everybody

In Xaml root element "Window" or "UserControl", one would typically find:
<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" <br />
xmlns:Infra="http://infragistics.com/DockManager" <br />
xmlns:MyLib1="clr-namespace:AbcFirm.Lib1"<br />
xmlns:MyLib2="clr-namespace:AbcFirm.Lib2" <br />
xmlns:MyLib3="clr-namespace:AbcFirm.Lib3" <br />
xmlns:sys="clr-namespace:System;assembly=mscorlib"<br />


1. Default namespaces
--------------------------------------------------------
One point worth noting, defaults reference CANNOT be removed, or changed even though XamlParser won't go online and visit the actual reference
<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />


Give it a try. If you remove or change these two defaults, you'd get compiler error. The following would NOT compile for instance.
<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentationXXXXX"<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xamlXXXXX"<br />
xmlns:sys="clr-namespace:System;assembly=mscorlib"<br />


These two defaults namespaces are probably defined in "XmlnsDefinition" tag in "AssemblyInfo.cs" of WPF dll.
<code>
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation[^]", "")]
[assembly: XmlnsDefinition("http"//ImUseless.com/DoNothing[^]", "x")]
</code>

So while Xaml processor wont go online and actually parsed the referenced url's - they are compiled into the referenced dll's and you cannot just put some garbage there!

This is described on MSDN[^]
<br />
The root element also contains the attributes xmlns and xmlns:x. These attributes indicate to a XAML processor which XAML namespaces contain the type definitions for backing types that the markup will reference as elements. The xmlns attribute specifically indicates the default XAML namespace. Within the default XAML namespace, object elements in the markup can be specified without a prefix. For most WPF application scenarios, and for almost all of the examples given in the WPF sections of the SDK, the default XAML namespace is mapped to the WPF namespace http://schemas.microsoft.com/winfx/2006/xaml/presentation. The xmlns:x attribute indicates an additional XAML namespace, which maps the XAML language namespace http://schemas.microsoft.com/winfx/2006/xaml. <br />



2. Custom namespaces
---------------------------------------------------------------
For actual namespace reference, which doesn't reference "Url" - they are for real, referenced namespace must exists (Or else compile error).
<br />
xmlns:MyLib1="clr-namespace:AbcFirm.Lib1"  <br />
xmlns:MyLib2="clr-namespace:AbcFirm.Lib2" <br />
xmlns:MyLib3="clr-namespace:AbcFirm.Lib3" <br />
xmlns:sys="clr-namespace:System;assembly=mscorlib"<br />
xmlns:igDock="http://infragistics.com/DockManager"  << NOTE: You don't necessarily need to use "clr-namespace", you can rely on [assembly: XmlnsDefinition] instead)<br />


In above example, you'd find from "AssemblyInfo.cs" (you'd need to add "using System.Windows.Markup") of relevant Infragistics's dll something similar to:
<br />
[assembly: XmlnsDefinition("<a href="http://infragistics.com/DockManager">http://infragistics.com/DockManager</a>[<a href="http://infragistics.com/DockManager" target="_blank" title="New Window">^</a>]", "...InfragisticDockPanel...")]<br />

dev
modified on Thursday, April 28, 2011 10:56 PM

GeneralRe: WPF namespaces reference Pin
Pete O'Hanlon27-Apr-11 21:53
mvePete O'Hanlon27-Apr-11 21:53 
GeneralRe: WPF namespaces reference Pin
devvvy28-Apr-11 16:55
devvvy28-Apr-11 16:55 
QuestionOpen a file from path on Hyperlink click in silverlight Pin
Piyush Nandanwar26-Apr-11 0:20
Piyush Nandanwar26-Apr-11 0:20 
AnswerRe: Open a file from path on Hyperlink click in silverlight Pin
Pete O'Hanlon26-Apr-11 0:30
mvePete O'Hanlon26-Apr-11 0:30 
GeneralRe: Open a file from path on Hyperlink click in silverlight Pin
Piyush Nandanwar26-Apr-11 0:41
Piyush Nandanwar26-Apr-11 0:41 
GeneralRe: Open a file from path on Hyperlink click in silverlight Pin
Pete O'Hanlon26-Apr-11 0:54
mvePete O'Hanlon26-Apr-11 0:54 
GeneralRe: Open a file from path on Hyperlink click in silverlight Pin
Piyush Nandanwar26-Apr-11 4:32
Piyush Nandanwar26-Apr-11 4:32 
GeneralRe: Open a file from path on Hyperlink click in silverlight Pin
Pete O'Hanlon26-Apr-11 4:36
mvePete O'Hanlon26-Apr-11 4:36 
GeneralRe: Open a file from path on Hyperlink click in silverlight Pin
Piyush Nandanwar26-Apr-11 4:42
Piyush Nandanwar26-Apr-11 4:42 
QuestionDATAGRID - WPF c# 2010 Pin
arkiboys25-Apr-11 21:20
arkiboys25-Apr-11 21:20 
AnswerRe: DATAGRID - WPF c# 2010 Pin
Tarun.K.S25-Apr-11 22:01
Tarun.K.S25-Apr-11 22:01 
GeneralRe: DATAGRID - WPF c# 2010 Pin
arkiboys25-Apr-11 22:41
arkiboys25-Apr-11 22:41 
GeneralRe: DATAGRID - WPF c# 2010 Pin
Wayne Gaylard25-Apr-11 22:57
professionalWayne Gaylard25-Apr-11 22:57 
GeneralRe: DATAGRID - WPF c# 2010 Pin
arkiboys25-Apr-11 23:02
arkiboys25-Apr-11 23:02 
AnswerRe: DATAGRID - WPF c# 2010 Pin
Pete O'Hanlon25-Apr-11 22:51
mvePete O'Hanlon25-Apr-11 22:51 
GeneralRe: DATAGRID - WPF c# 2010 Pin
arkiboys25-Apr-11 23:04
arkiboys25-Apr-11 23:04 
GeneralRe: DATAGRID - WPF c# 2010 Pin
Pete O'Hanlon25-Apr-11 23:36
mvePete O'Hanlon25-Apr-11 23:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.