diff --git a/src/Uno.UI/UI/Xaml/Media/ImageSource.macOS.cs b/src/Uno.UI/UI/Xaml/Media/ImageSource.macOS.cs index ae838b02018c..92895369041c 100644 --- a/src/Uno.UI/UI/Xaml/Media/ImageSource.macOS.cs +++ b/src/Uno.UI/UI/Xaml/Media/ImageSource.macOS.cs @@ -66,7 +66,7 @@ public bool HasSource() /// internal NSImage OpenBundle() { - ImageData = OpenBundleFromString(BundleName) ?? OpenBundleFromString(BundlePath); + ImageData = OpenBundleFromString(BundleName) ?? OpenResourceFromString(BundlePath); if (ImageData == null) { @@ -86,6 +86,23 @@ private static NSImage OpenBundleFromString(string bundle) return null; } + private static NSImage OpenResourceFromString(string name) + { + if (name.HasValueTrimmed()) + { + var extension = Path.GetExtension(name); + var fileName = name.Replace(extension, string.Empty); + + var path = NSBundle.MainBundle.PathForResource(fileName, extension); + + return !string.IsNullOrEmpty(path) + ? new NSImage(path) + : null; + } + + return null; + } + internal async Task Open(CancellationToken ct) { using (