I am developing an app with WPF.
In my case, the users have 2 monitors. When he opens the app in the secondary screen, it will load data for nearly 5 seconds. During this period, he may turn to the primary screen for personal stuff, like visit Facebook or visit twitter.
After the data are loaded, a dialogbox should be prompted. What bothers me is that it often shows in the primary screen where he deals with personal stuff, not the secondary screen where he opens the app. The dialog window is supposed to show on the top of the app.
I am thinking it's because that the app is not active when the data are loaded. Do you guys have any idea?
I know that the MessageBox.Show() has a "owner" parameter can fix this. How can I automatically get the correct owner? I am using a PRISM pattern so that it's not easy for me to find the window as the owner.
Code:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
await Task.Delay(5000);
MessageBox.Show("Loaded!");
}
}