I am attempting to create a simple slideshow in my Uno app. What I have works in UWP, but fails in WASM. My code looks like this:
public void SlideShowPageLoaded(object sender, RoutedEventArgs args)
{
vm.URL = vm.SlideList[CurrentIndex].URL;
timer = new DispatcherTimer();
timer.Tick += dispatcherTimer_Tick;
timer.Interval = new TimeSpan(0, 0, this.Interval);
timer.Start();
}
private void dispatcherTimer_Tick(object sender, object e)
{
this.GetNextIndex();
try
{
vm.URL = vm.SlideList[CurrentIndex].URL;
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
When the page loads, I set the URL for my image, then create a DispatchTimer. The Tick event just changes the URL. The image xaml looks like:
<Image x:Name="imageControl" Source="{Binding URL, Mode=OneWay}" />
This works fine in UWP, nothing happens in WASM. I'm guessing that the DispatchTimer is not supported? Are there other options that I can use?
Problem is solved. The information I initially provided was incomplete. The SlideShowPage is created by Frame.Navigate. In the UWP implementation that worked UWP called OnNavigateTo event first, then called the SlideShowPageLoaded. On WASM, SlideShowPageLoaded was called before the OnNavigateTo event handler, hence the data was not initialized.
I reconfigured my call to initialize my data in the OnNavigateTo handler and ignored the SlideShowPageLoaded event to resolve the problem.