My WPF app consists of a NavigationWindow, and then a set of Pages defined as separate xaml files. The NavigationWindow loads and displays the various pages in turn.
My problem is that loading the pages is expensive and may fail. Thus, I want to preload the page in the background, and then only call Navigate() once the page has finished loading.
In pseudocode what I would want is
Page nextPage;
try
{
nextPage = LoadPageFromURI(new URI(...));
}
catch
{
/// constructor of the page threw an exception ... load a different page
}
myNavigationWindow.Navigate(nextPage);
I can't however find framework functions to do what I want. Could someone who knows WPF better give me a hand? Thanks you!