diff --git a/src/Avalonia.Base/Media/Imaging/Bitmap.cs b/src/Avalonia.Base/Media/Imaging/Bitmap.cs index fbe9370edc..45a547f16a 100644 --- a/src/Avalonia.Base/Media/Imaging/Bitmap.cs +++ b/src/Avalonia.Base/Media/Imaging/Bitmap.cs @@ -240,6 +240,16 @@ namespace Avalonia.Media.Imaging return AvaloniaLocator.Current.GetRequiredService(); } - IRef IImageBrushSource.Bitmap => PlatformImpl; + IRef? IImageBrushSource.Bitmap + { + get + { + // TODO12: We should probably make PlatformImpl to be nullable or make it possible to check + // and fix IRef in general (right now Item is not nullable while it internally is) + if (PlatformImpl.Item == null!) + return null; + return PlatformImpl; + } + } } }