wpf icon indicating copy to clipboard operation
wpf copied to clipboard

Markup compiled XAML 2009

Open Zhentar opened this issue 7 years ago • 11 comments

XAML 2009 has been out for a few years now, and includes some features that would be quite nice to use with WPF in markup compiled XAML. What currently blocks XAML 2009 support? Where could community contributions help to move it forward?

Zhentar avatar Dec 04 '18 19:12 Zhentar

Related issue for one of these items: https://github.com/dotnet/wpf/issues/45

dotMorten avatar Dec 04 '18 19:12 dotMorten

XamlReader.Load code paths in WPF support most of those features.

If I recall correctly, the markup compiler (in PresentationBuildTasks.dll) and designer support (VS Xaml Tools) would be the major blockers. After we replumbed WPF in .NET 4.0 to use System.Xaml, we weren't able to justify spending our smaller resources on migrating the WPF MarkupCompiler to use System.Xaml. I'm sure there will be other issues also...perhaps BAML format and reader/writer needs extending for some of this work?

rrelyea avatar Dec 04 '18 19:12 rrelyea

we weren't able to justify spending our smaller resources on migrating the WPF MarkupCompiler to use System.Xaml.

Perhaps if we can get some guidelines how to do that, the community could provide those resources?

dotMorten avatar Dec 04 '18 20:12 dotMorten

I'm sure there will be other issues also

~~In case it helps, here's a behavior difference we've found between System.Windows.Markup in WPF and System.Xaml... it's a real edge case, so I figured it may help to bring it up here (if not, ignore me).~~

~~Our WPF app predates System.Xaml, and we've been using WPF's XamlReader / XamlWriter for serializing / deserializing our own objects for a while now.~~

~~One interesting "issue" we had when we tried moving that stuff to use System.Xaml: turns out that using WPF's XamlReader / XamlWriter, we can serialize / deserialize an instance of a type that doesn't have a public parameterless constructor, when the type has a [TypeConverter] attribute applied (but System.Xaml cannot save / load instances of such types).~~

~~Here's a complete repro to show the details of what I'm talking about (just a .csproj and a .cs file, under 100 lines between the two): https://gist.github.com/airbreather/1ca3ef7698b3539ac3cd1170144a6561~~


Super late edit: having learned much more about this in the past few years since I wrote that comment, I think this might just be a feature of the WPF XAML schema context helping us out, not anything intrinsically missing from System.Xaml itself. Probably just continue ignoring this comment 😬.

airbreather avatar Dec 04 '18 20:12 airbreather

can someone explain Markup Complied XAML? the diff from normal xaml?

usernamedd avatar Apr 02 '20 02:04 usernamedd

"normal xaml" as in a .xaml file in a WPF project (usually paired with a .xaml.cs file) is Markup Compiled XAML. Currently, only XAML 2006 (i.e. the original version) is supported. XAML 2009 adds a few features that would be nice to have available.

Zhentar avatar Apr 09 '20 20:04 Zhentar

How come certain XAML2009 features do actually seem to work in markup compiled XAML? I know the documentation states this is not the case, but for instance I have had success using x:Reference within a xaml/xaml.cs usercontrol.

DavidHollman avatar Mar 03 '21 14:03 DavidHollman

People have been waiting for this feature for years. I remember reading about XAML2009 in WPF Unleashed by Adam Nathan as this new hot thing that's coming soon to WPF, but it never happened. Heck, I even asked about it on the recent .NET Conf: Focus on Windows, and @coolcsh said he didn’t know what I’m talking about 😁 (kudos to his team anyway).

It would be so nice to finally have this feature in .NET 6.0, and use x:Int32 without importing mscorlib, x:Arguments to instantiate object with non-default constructors, x:TypeArguments for generic types, x:FactoryMethod for things such as Guid.NewGuid, etc.

yariker avatar Sep 16 '21 03:09 yariker

2009 was a pretty long time ago now. It would be awesome to see these features added as it would make certain things in WPF a lot easier 🙂

DanJBower avatar Apr 28 '22 16:04 DanJBower

This is still very much needed for those who still write desktop apps on WPF. I need it mainly for x:TypeArguments

LevYas avatar Jan 03 '24 16:01 LevYas

It is beyond me how basically the most mature and developed C# UI solution can't adopt XAML 2009 which allows generics, an important language feature, for 15 years already...

Metadorius avatar Sep 26 '24 19:09 Metadorius