0

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.

Veksi
  • 3,556
  • 3
  • 30
  • 69

1 Answers1

0

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.

ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196
  • The term "Windows XAML" is in fact a ambiguous by nature. I would say "Windows XAML" is the XAML provided by the Windows OS (the one used by UWP) in the Windows.UI.Xaml* namespace (aka "WUX"). WinUI3 would be more the "Microsoft Xaml" provided by WinUI3 (which is not provided with Windows but with the Windows App SDK - all these names that Microsoft came up with are so *dumb and confusing*!) in the Microsoft.UI.Xaml.* namepace (aka "MUX"). – Simon Mourier Jan 16 '23 at 07:48
  • Maybe not entirely compatible to compare if Android APIs to iOS in the sense that the ask ask was what IF one could write WinUI3 XAML and use it ONLY in Windows when on Maui. It appears it is not possible. – Veksi Jan 16 '23 at 10:00
  • 1
    Unfortunately, wanting to use it ONLY on Windows does not help it work within Maui. Its a valid question, but it simply does not work that way. I was trying to make the point that it is a different **UI architecture** (in the same way that iOS and Android are different UI architectures), even if you are running on Windows. – ToolmakerSteve Jan 17 '23 at 21:06