About getting the ImageSource's Size

I tried to trace the Size of a ImageSource in the MainView uno by debug_log. When I just open the app, the log showed 0,0 for the size. Then the app loaded completely and showed the image, and the log changed from 0,0 the 640,425 at the same time.

Problem are that:

  1. The size is correctly traced only until the image is completely showed. --> I want to know the height before showing the image.

  2. I dun know why the app ran twice --> it might be a reason why the size(both height and width) couldn’t be got correctly at the begining.

A reference about the bug reported: https://www.fusetools.com/developers/forums/bug_reports/mainview_loaded_twice?page=1#post-849e064a-efc1-4e11-bc28-b9a4aaaf91b9

Please help. Thank you.

1a. The ImageSource.State reflects the current state of loading. When loaded the Size and PixelSize property will be available. You can subscribe to Changed to be notified of changes.

1b. At the moment you can force the image to preload with <Image File="name.png" FilePreload="true"/> and the Size should be availble when you request it. In an upcoming version this changes to <Image File="name.png" MemoryPolicy="PreloadRetain"/>.

1c. If you want finer control of when to attach the image to the UI you can use a BundleFileImageSource directly. <BundleFileImageSource BundleFile="name.png"/> (the two preload options are also available). You can then from Uno code attach this to an Image at the point you desire.

Two) We’d need to see a full example to figure out what the constructor is executed twice.