Is Loose XAML a .NET / CLR version loaded depending on the reference namespace?

I just read WPF Unleashed, and he noted that the button will look different depending on the XMLNS used.

So, I tried the following and this, and it hit on the right.

In this code, a 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, a non-global button is loaded.

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

Am I just trying to figure out what is really happening? Is it hard-coded that PresentationHost.exe loads 4.0 CLR when it sees the namespace ../ netfx / 2009 / ... ?

+5
source share
1 answer

Inside PresentationFramework.dll there is a mapping using XmlnsDefinitionAttribute .

When the compiler enters the namespace, it looks for the specified DLLs that match 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 reaches winfx/2006 , it will look for the corresponding XAML 2006 DLLs. If it gets into netfx/2009 , it will look for the XAML 2009 DLL.

+3
source

Source: https://habr.com/ru/post/1201088/


All Articles