简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM