-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
I've run into exceptions when instantiating an SvgImage as follows:
sampleButton = new SvgImage
{
IsVisible = false,
SvgAssembly = typeof(App).GetTypeInfo().Assembly,
HeightRequest = 44,
WidthRequest = 44,
};
And, at a later point in time:
sampleButton.IsVisible = true;
sampleButton.SvgPath = "MyPath.MyImage.svg";
The SvgImage.RenderSvgToCanvas() method is invoked even though the SvgImage is initially invisible. The method fails because LoadedGraphic is null:
public IImageCanvas RenderSvgToCanvas (...)
{
var originalSvgSize = LoadedGraphic.Size; // Exception because LoadedGraphic = null
var finalCanvas = createPlatformImageCanvas (outputSize, finalScale);
...
}
A possible solution might be:
public IImageCanvas RenderSvgToCanvas (...)
{
var finalCanvas = createPlatformImageCanvas(outputSize, finalScale);
if (LoadedGraphic == null)
{
return finalCanvas;
}
var originalSvgSize = LoadedGraphic.Size;
...
}
Metadata
Metadata
Assignees
Labels
No labels