Uno.Shared Page/UserControl Events Fired In Different Order ( UPW vs WASM ) #4072
Labels
kind/bug
Something isn't working
triage/untriaged
Indicates an issue requires triaging or verification
What I observe is the following: on UWP the logs indicate that the UserContol's Load event is fired first and the Page's Load event is fired second. On WASM the logs have the other way around (page first then the user control).
Page
x:Class="UnoTest2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UnoTest2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Loaded="OnLoad" <-THIS EVENT FIRES AFTER THE USER CONTOL'S ON UWP; BUT FIRST ON WASM ->
Current behavior
I am using a XAML defined Load Event on a Page and a UserContol to provide initialization of a ViewModel.
Both use XAML to declare the respective DataContexts. There are then Notification event handles that listen for changes that occur. When the LOAD events sequence is fired in a different order, the event listeners are not initialized properly on WASM when they work properly on UWP.
Expected behavior
The sequence of events should be consistent between UWP & WASM.
How to reproduce it (as minimally and precisely as possible)
2, Use Xaml to create an event handler for the Loaded event on both the page and the user control (ex: Loaded="OnLoad" )
4 Run the project on both UWP and WASM
Workaround
I put in an
await Task.Delay(1000);
before the initialization of the event listeners. It was a total, hack, but it allowed both load events to be completed in whatever sequence they occurred, and the underlying DataContext to be initialized - then after the delay - the event listenersawait Task.Delay(1000); /* HORRIBLE HACK */ vuMod.Squares.CollectionChanged += this.Squares_CollectionChanged; vuMod.Circles.CollectionChanged += this.Cicrles_CollectionChanged;
Environment
Nuget Package:
Nuget Package Version(s):
Affected platform(s):
IDE:
Relevant plugins:
Anything else we need to know?
The text was updated successfully, but these errors were encountered: