Sunday, April 24, 2011

How to make your xlmns pointing to URL

Quite a few WPF developer knows that we can customize on how XAML namespaces represents the actual assembly (.dll). I too sometimes forgot how to customize it that is why I blogged this out.

When we represent the assembly/namespaces (dll) in our XAML; we do specify like this
   
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

When we have our own namespace or assembly of controls we declare something like the bottom so that we could use some controls.

xmlns:custom="clr-namespace:WpfCustomControlLibrary1;assembly=WpfCustomControlLibrary1"


Actually, we also do namespacing like that one on the top which represent the presentationcore.dll To do it, we can put XMLDefinition in our namespaces.
[assembly: XmlnsDefinition("http://www.gioVhan.com", "WpfCustomControlLibrary1")]
namespace WpfCustomControlLibrary1
{
.....
}

In this way, the "http://www.gioVhan.com" is the representation of our assembly thus we can type like.







This is a very cool feature in WPF. When designing your own assemblies, you can create something like this. It will represent a more and clear namespace rather than pointing to clr-...

I will check on VS2010/EF4.0 if this feature was changed.

Thanks.

2 comments:

Perlyn Per said...

Hi Gio,
I represent TRC Group, a head hunting firm for Investment Banks in Singapore. I have a job opportunity which I would like to discuss with you. If you are keen, please contact me at pper@trcgroup.com or send me your contact details and I will give you a call.
Kind regards,
Perlyn Per

Gio said...

I have check in VS2010, the feature is still there. In this we can have declarative namespace represented on a URL format.