Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are xmlns=[some url] attributes in the beginning of WPF xaml files for?

Tags:

url

wpf

xaml

I noticed in the beginning of a xaml we have stuff like

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

The only other usage I see for xmlns is importing namespaces from my assemblies. Are these also instances of importing assembly? From a URL? If not, what do they refer to? What if the computer is not connected to the internet?

like image 275
Louis Rhys Avatar asked Jan 28 '26 00:01

Louis Rhys


1 Answers

this is not related to xaml, but to xml in general.

The target of namespaces is to be able to uniquely identify xml objects.

take a look here.

For example, it allows to have two "Customer" node, with different namespaces. Programs can then distinguish if it's a customer node from system A or system B.

This can be compared to C# namespaces also. The "Control" class exists both in System.Windows and System.Windows.Forms and even in System.Web.Ui... same name, but "ownership" are different according the namespaces.

One thing to know, it's only a declaration. the namespace is a freetext, the http:// format is just a convention, and no download of the target uri will occur.

like image 104
Steve B Avatar answered Jan 30 '26 16:01

Steve B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!