null controls during page load

One program I've been seeing quite a bit with Reunion 0.5.5 is that some controls are null when I reference them from the constuctor.

Solution: I put all of the referenced controls into a DispatchTimer event (which is a timer that runs on the UI thread). Then I created a flag which is only set at the end of the timer function. At the beginning of the timer function call:

if (this.IsLoaded == false)
{
        return;
}

This will effectively keep having a stab at it until all the controls are available to be referenced. Once the full body of code has been run then the timer can switch itself off.

Comments

Popular posts from this blog

Setting a colour from a StaticResource in C#

ParallaxView suddenly no longer supports direct content

Resource Strings - UWP vs net 5