Event triggered after Window and UserControl is fully displayed? #15253
Unanswered
mkj-stonehill
asked this question in
Q&A
Replies: 1 comment
-
|
Did you try the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
My MVVM application (using Avalonia 11.0.10, running on Linux) has a main Window, whose Context is set to a UserControl which is just a splash screen. The splash screen view model has an initialization function which does a bunch of work, and when it is done, the main window Context is set to a different UserControl (where the user logs in).
I'm trying to get the splash screen to be visible as fast as possible, and have the init function run while that is displayed. I've tried making the Init function async, but it still usually completes before the main window and splash screen has fully displayed.
Empirically, it seems that the Activated event (on the main window) is about the last one called when the application starts up. But even when calling the init function from an Activated handler, the window is not fully displayed. Often it is just black, with the window border around it. Sometimes, the bitmap is displayed, but hasn't been scaled to fit. If I add add an "await Task.Delay(100);" to the top of my init function, the window is fully displayed; but that's just cheesy.
Is there an event which occurs after everything is displayed? Either in the main window, or in the UserControl which is my splash screen? If not, any other suggestions for ensuring the splash screen gets fully displayed while the initialization happens?
Beta Was this translation helpful? Give feedback.
All reactions