One of the issues I'm facing while converting WPF application from NET Framework 4.7 to .Net Core 3.0 is a problem with mapping primitive types like Double in XAML. In NET Framework this XAML has worked perfectly:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
>
<sys:Double x:Key="BaseSize">10</sys:Double>
</ResourceDictionary>
However mscorlib does not exist in .Net Core. How can I map primitive types in XAML in .Net Core 3?
Had tried this: https://docs.microsoft.com/en-us/dotnet/framework/xaml-services/built-in-types-for-common-xaml-language-primitives
But for WPF this does not work as it is stated here:
"In WPF, you can use XAML 2009 features but only for XAML that is not markup-compiled. Markup-compiled XAML for WPF and the BAML form of XAML do not currently support the XAML 2009 keywords and features."
NET Core 3.1 Support for ASP.NET Core, WinForms, and WPF Controls (v19. 2.5)
Most WPF apps consist of both XAML markup and code-behind. Within a project, the XAML is written as a . xaml file, and a CLR language such as Microsoft Visual Basic or C# is used to write a code-behind file.
Extensible Application Markup Language (XAML /ˈzæməl/ ( listen)) is a declarative XML-based language that Microsoft developed for initializing structured values and objects. It is available under Microsoft's Open Specification Promise.
You can use the exact same markup when targeting .NET Core 3.0, i.e. xmlns:sys="clr-namespace:System;assembly=mscorlib"
does actually work. Any reference to mscorlib
is type forwarded to System.Runtime
automatically.
Try to build the solution or take a look at this GitHub issue if you don't believe me.
Edit: Starting with .NET Core 3.1, you should replace assembly=mscorlib
with assembly=System.Runtime
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With