Home > Back-end >  Is it possible to use platform native (Windows) XAML in Maui?
Is it possible to use platform native (Windows) XAML in Maui?

Time:01-17

This is a bit of a continuation to How could one to merge resource dictionaries either dynamically or in compile time? (or to .NET MAUI: can we also have platform-specific XAML?).

I was reading https://learn.microsoft.com/en-us/windows/apps/design/style/xaml-theme-resources#the-xaml-type-ramp to see about Fluent design guidelines. Then I thought about applying them to Maui. Using "the technique of merge dictionaries" I thought that maybe it's possible to take Windows native XAML from https://github.com/microsoft/microsoft-ui-xaml/blob/cb181acede22577c59c5dc250361d3340252f4e9/dev/CommonStyles/TextBlock_themeresources.xaml#L21 and put that to Windows only XAML.

But of course that does not work like that, since eventually the Maui XAML compiler and Maui application load the XAML and they do not recognize that. Even if it would involve only Windows platform.

But I wonder if someone knows to tell if it is possible (or not) use Windows native XAML like that?

I suspect the answer is similar to Can I use existing WinUI3 controls in MAUI project?, but I'll ask explicitly in any case.

CodePudding user response:

No; that wouldn't make sense:

  • WIndows XAML represents WinUI 3 controls (part of Windows App SDK), and their properties. Many properties are specific to Windows.
  • Maui XAML has its own cross-platform controls. These are designed to be easily mapped to native controls on different platforms.

This is sort-of-like asking if iOS APIs can be used on Android. Not compatible.

Though the differences are not as extreme as between iOS and Android; see next section.


OTOH, there are strong similarities in some features between all XAMLs (WPF, Xamarin.Forms/Maui, Windows): XAML Standard; XAML dialect alignment.

That doc explains the situation; Microsoft did not succeed in making a "common subset" that all XAMLs would support.

But they did identify differences, and have made a few additions here and there to increase similarity.

  • Related