When you create a new WpfApplication project in Visual Studio you get the following XAML. Copying and pasting the URL http://schemas.microsoft.com/winfx/2006/xaml/presentation into the browser I expected to see the XSD file definition but I get an error. Why?
Thanks.
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
</Grid>
</Window>
A namespace is a URI (a URN or a URL), but a URI is not always a URL. The URI used for namespaces is meant to uniquely identify names to prevent clashed. The XML Namespaces Working Group at the time decided to use a technique already know to uniquely identify things: URIs.
As a result, many people think it should actually point to something real. Occasionally that is true, but more often it is not, and it is not meant to be. It is an identitifier, not a location.
In the case of schemas, it is can be used to denote the target namespace, which is the namespace that must be used in documents that need to validated against the schema. To obtain the schema, you will have to ask the vendor. In this case, the schema can be found at a location similar or equal to
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas
, look forwpfe.xsd
(however, to confuse matters more, Microsoft has decided to create an alias for the target namespace, which is why you will not see the same namespace you mentioned).The problem is most of wpf developer knows how it works but when you going to explain, it's become much difficult .. below is my try ... due to simplification it become large but i hope if you read to the end, you will understand how the definition thing works ..
Scenario:
I am a wpf beginner developer and searching for a wpf spinner on goggle. i got a link of font.awesome.wpf .. so i started to trying it. below code is written in document to add the spinner ..
Wow great .... It's working fine !!! ...
Suddenly!! i discover that i added a line there
Not something like
then how visual studio knew which
dll
contain the ImageAwesome class!!! ... I added onlyFontAwesome.WPF.dll
through nuget ..nothing else i did.. no additional xsd or xml file is there.. The schema link(http://schemas.fontawesome.io/icons/) is not available ...then how?? ...Strange!!However after 1 hours i ended up with below code..
The noticable part is
fa:ImageAwesome
andfa:CssClassNameConverter
classes... They are fromdifferent namespace
(using code behind i already checked it).. and i did not specified one extra line to specify any ofFontAwesome.WPF
orFontAwesome.WPF.Converters
namespace.. then how the magic going on!! ..Solution:
So i downloaded the source code of font.awesome.wpf .. and started search for the text
http://schemas.fontawesome.io/icons/
there ... and finally i found the below lines inassembly.cs
of font.awesome.wpf project..And the whole thing (the magic trick!!) revealed to me ..
In
assembly.cs
file the component defined thehttp://schemas.fontawesome.io/icons/
namespace .. so when i add fontawesome.wpf dll ... visual studio got it's namespace definition using refection .. and so how vs knows where thefa tag refers to
... So this is how it resolved to me... :)Some theory