MVVM ExecutePaintSurfaceCommand fires before image loaded. #1756
Unanswered
jazzzsoftware
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I am using SkiaSharp with Xamarin Forms and Prism. Please see here for my previous post with more detail on the setup.
I am using Xam.Plugin.Media to pick a photo from the gallery or take a new one.
I noticed that after selecting/taking a photo that no image was displayed. If I selected another photo the previous was displayed. The shown image in the app was out of sync with the selected one.
I debugged this problem and found that ExecutePaintSurfaceCommand was fired before my image was loaded from the gallery.
I fixed this by making the SKCanvasView a parameter into the ExecutePaintSurfaceCommand, making SKCanvasView a field and then calling _canvasView.InvalidateSurface(); after my image was loaded.
This has a bad smell about it. Is there a better way?
XAML:
ViewModel:
and
Thanks
Mark.
All reactions