Sam Afshari's Notes
  • GitHub
  • Twitter/X
  • All posts
  • Ed
  • NuGets
  • POIWorld
  • RedCorners

Notes on Uno Platform - Wed, Feb 17, 2021

I wanted to port Replicate Resync to MacOS. Resync is originally written in WPF, and I chose Uno Platform for porting it to MacOS.

Uno Platform’s XAML is more UWP style, so the first thing I did was translating the WPF XAML to UWP. The UWP XAML worked almost perfectly on Uno Platform. The biggest issue I had was with the menu bar. The implementation of regular UWP menu bar looks very glitchy on MacOS at the moment, and the native style menu keeps vanishing items once they have a Click or Command handler assigned to them.

Other obstacles were file and directory pickers. I used NSOpenPanel and NSSavePanel for that:

var dialog = NSOpenPanel.OpenPanel;
dialog.CanChooseFiles = false;
dialog.CanChooseDirectories = true;
if (dialog.RunModal() == 1)
{
    var url = dialog.Urls[0];
}

To pick files you can set CanChooseFiles to true and CanChooseDirectories to false.

To set the file formats, use dialog.AllowedFileTypes = new string[] { "jpg", "png" };.

Use NSSavePanel.SavePanel for save file picker.

To set the window title: Dispatch(() => AppKit.NSApplication.SharedApplication.MainWindow.Title = Title);

Back to Home


© Sam Afshari 2024