Search code examples
c#cocoaxamarinxamarin.mac

Xamarin.Mac - Show icon/image before Window Title


I am trying to show an image/icon before the title of window, just like in finder. I have used Window.SetTitleWithRepresentedFilename but it just shows a generic icon not that png file I want to show.enter image description here


Solution

  • public override void WindowDidLoad()
    {
        base.WindowDidLoad();
    
        Window.RepresentedUrl = new NSUrl(Path.GetFullPath("check.png"));
        var btn = Window.StandardWindowButton(NSWindowButton.DocumentIconButton);
        btn.Image = NSImage.ImageNamed("check");
    }