SwiftWinRT icon indicating copy to clipboard operation
SwiftWinRT copied to clipboard

Some UI controls just crash

Open ericsink opened this issue 3 years ago • 3 comments

The XamlApp sample is a place where I experiment with support for various WinUI controls.

Controls that work:

  • TextBlock
  • Button
  • CalendarDatePicker
  • DatePicker
  • Slider

Controls that crash:

  • TextBox
  • RatingControl
  • ColorPicker

ericsink avatar Jun 29 '22 14:06 ericsink

You can refer https://github.com/CommunityToolkit/Microsoft.Toolkit.Win32/tree/master/Microsoft.Toolkit.Win32.UI.XamlApplication to implement a WinRT object inherited from Windows.UI.Xaml.Application.

After you implement this object, you can initialize the WinRT XAML via create instance of this object after initializing the COM.

I have made a XAML Islands based toolchain called Mile.Xaml. Here is the Mile.Xaml.Application object implementation: https://github.com/ProjectMile/Mile.Xaml/tree/main/Mile.Xaml. Here is the Mile.Xaml BlankApp example: https://github.com/ProjectMile/Mile.Xaml.Samples/blob/main/MileXamlBlankApp/WinMain.cpp

I hope these XAML Islands related information can help you. Something may be similar for WinUI 3.

Kenji Mouri

MouriNaruto avatar Jan 06 '23 04:01 MouriNaruto

Looks like you can get pretty far if you just load app.xaml as-is in runtime and implementing IXamlMetadataProvider by forwarding to Microsoft.UI.Xaml.XamlTypeInfo.XamlControlsXamlMetaDataProvider

This is C# but I guess Swift will behave similarly.

image

driver1998 avatar Feb 01 '23 09:02 driver1998

See https://github.com/driver1998/WinUIMinimalXaml for the demo code. (credit goes to @sylveon)

driver1998 avatar Feb 01 '23 09:02 driver1998