简体   繁体   中英

Async navigation in Prism Scoped Region

I have a WPF project based upon PRISM 6.1.0 Shell exposes TabControl as a "MainRegion". I need to display several views that loads data from the database. Data loading process takes time, and UI remains frozen. I've tried to RUN this procedd async like this

await Task.Run(() =>
            {
                RegionManager.RequestNavigate(RegionNames.MainRegion, "FirstView", parameters);
                RegionManager.RequestNavigate(RegionNames.MainRegion, "SecondView", parameters);
                ....
                RegionManager.RequestNavigate(RegionNames.MainRegion, "LastView", parameters);
            });

but nothing happens, UI stays frozen untill last view will be loaded and only then displays all views in TabControl...

Is there any way to load Views asynchronously?

Navigate to your View first, and then have your View async load its data. You can show a busy indicator control to show something is being loaded in the background. When the data has been loaded, the busy indicator will hide and the View will display the newly loaded data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM