unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
9.04k stars 734 forks source link

Dialog (`ShowAsync()`) in `MainPage.Loaded` event #4550

Open Basyras opened 4 years ago

Basyras commented 4 years ago

Current behavior

Calling ContentDialog.ShowAsync() in MainPage.Loaded event does not showing dialog after app started (Only in Wasm project).

Expected behavior

ContentDialog should be displayed.

How to reproduce it (as minimally and precisely as possible)

Create project with blank Uno app template and add code in MainPage.xaml.cs:

        public MainPage()
        {

            this.InitializeComponent();
            this.Loaded += async (s, a) =>
            {
                var dialog = new ContentDialog();
                await dialog.ShowAsync();
            };
       }

Workaround

simple await Task.Delay(1000); before calling await dialog.ShowAsync(); solve this issue

Environment

Nuget Package:

Nuget Package Version(s): NETStandard.Library: 2.0.3 Uno.UI.RemoteControl: 3.2.0 Uno.UI.WebAssembly: 3.2.0 Uno.Wasm.Bootstrap: 1.3.4 Uno.Wasm.Bootstrap.DevServer: 1.3.4

Affected platform(s):

Skia and WASM covered by #15207

IDE:

Relevant plugins:

Anything else we need to know?

This issue may be releated to #3519 (if yes we can close my issue)

jeromelaban commented 4 years ago

Thanks for the report!

It is indeed related to #3519. The Loaded event is not raised at the proper time, causing this issue.

Youssef1313 commented 11 months ago

Will be fixed with https://github.com/unoplatform/uno/pull/14528 for Skia and Wasm (other platforms need to be tested)