I have a
GridView representing input sources. I have a script attached to the
GridView.Loaded event so I can set the
SelectedValue correctly based on whether the receiver is already turned on and, if so, what it’s input source is. Here is a fragment:
var avrSwitch = App.GetDeviceAttribute("Main.Switch"); var isAvrOn = (avrSwitch == "On"); alert("AVR state is " + avrSwitch);
In the designer simulator and on my iOS device, the alert displays that the AVR state is “unknown” even when it’s on or off.
But if I insert an
alert("Starting") before anything else then the alert for the AVR state reports the correct value.
I suspect that the natural delay before I manually dismiss the “Starting” alert gives something in HR a chance to settle in so the
Main.Switch value is then retrieved correctly.
Is there another way to accomplish this that would avoid whatever I’m running into? If I need to I can introduce an arbitrary delay into the script, but I’d rather avoid that if I could.
Thanks for any suggestions.