Can XAML 2009-related markup extensions be used in WPF? Can XAML 2009-related markup extensions be used in WPF? wpf wpf

Can XAML 2009-related markup extensions be used in WPF?


I'll start from the end:


Why is there so much confusion regarding all of this?

Perhaps because so far, including a version of WPF 4.5, almost completely lack of support XAML 2009. Freestyle quote from the Matthew MacDonald WPF 4.5, Chapter 2 book:

Minimum improve XAML 2009 is still not fully implemented. They only support unrelated files XAML, but not resource type of Page (compiled resource), which are used everywhere. Probably, XAML 2009 will never be a fully integrated part of WPF, because it provided improvements are particularly not important and as any change in XAML compiler generates problems of security and performance.

Regarding the future of XAML 2009, then we can not say for sure when it will fully support, but we know that at the moment it does not exist.


Can these specific extensions be used in writing WPF applications? Are there any limitations in using them?

Yes, some extensions may be used in WPF 4.0 and WPF 4.5, for example: x:Array and other types, as well as x:Reference, x:FactoryMethod. I personally do use types in XAML 2009 and did not notice any bugs.

About the x:Reference can say, that in Visual Studio 2010 it does not work as it should: when using x:Reference as the Target of a some Control, the Visual Studio designer throws an InvalidOperationException exception with the message:

Service provider is missing the INameResolver service.

The project will compile and execute without any issues, but the Design canvas where the x:Reference appears will be disabled because of the exception. Personally, I have it sometimes appears, sometimes not, but it should be ignored.

But I almost know exactly what in version WPF 4.5 and perhaps for the Visual Studio more than in 2010 this bug has been fixed. For more info see this link.

About x:FactoryMethod here too, not everything went smoothly, for me in WPF 4.0, VisualStudio 2010 program is not compiled with it. Was also created a bug-report on connect.microsoft.com, but representatives of Microsoft said that:

The WPF team has recently reviewed this issue and will not be addressing this issue as at this time the team is focusing on the bugs impacting the highest number of WPF developers. If you believe that this was resolved in error, please reactivate this bug with any necessary supporting details.


Can XAML 2009 be used (in whole or in part) in WPF applications?

A definite answer: partially can be used, but maybe not for every version of WPF and Visual Studio.

If your project is planned in the future ported to the WPF version < 4.0 or more later, or on other platforms, such as Silverlight, Windows Phone, I think is better to avoid XAML 2009, because there is no guarantee that they will be it, at least partially supported. For example, in Silverlight there is no support in XAML 2009, there is even the XAML 2006 is not fully supported. It may be that a large part of the project can be dependent on XAML 2009, accordingly have to spend a certain amount of time and resources to to get rid of of this dependence. In this situation it is better to use a more universal solutions.

If you are using WPF 4.0 and higher, and there is no plan ported to the other platforms, I think partially it will be possible to use XAML 2009, after having tested it.

For more information, I recommend to familiarize yourself with XAML 2009 notation:

MSDN: Microsoft Domain-Specific Languages