Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loose XAML is version of .NET/CLR loaded dependent on referenced namespace?

Tags:

c#

.net

clr

wpf

xaml

I have just been reading WPF Unleashed and it mentioned that the button will look different depending on the XMLNS used.

So I tried the following and it and it bang on right.

In this code the glossy button is loaded.

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <StackPanel Height="40">
        <Button Content="Button1"/>
    </StackPanel>
</Page>

In this code the non-glossy button is loaded.

<Page xmlns="http://schemas.microsoft.com/netfx/2009/xaml/presentation">
    <StackPanel Height="40">
        <Button Content="Button1"/>
    </StackPanel>
</Page>

I am just trying to figure out what actually is happening? Is it just hardcoded that the PresentationHost.exe loads the 4.0 CLR when it sees the ../netfx/2009/... namespace?

like image 958
MajorInc Avatar asked Oct 21 '22 02:10

MajorInc


1 Answers

Inside PresentationFramework.dll there is a mapping using the XmlnsDefinitionAttribute.

When the compiler hits the namespace, it looks for the specified dlls matching the target XAML namespace:

[System.Windows.Markup.XmlnsDefinitionAttribute("http://schemas.microsoft.com/xps/2005/06", "System.Windows.Media.Animation"),
System.Runtime.CompilerServices.CompilationRelaxationsAttribute(8)

If it hits winfx/2006 it will look for the XAML 2006 corresponding dlls. If it hits netfx/2009 it will look for the XAML 2009 dlls.

like image 151
Yuval Itzchakov Avatar answered Oct 22 '22 16:10

Yuval Itzchakov