开发者

Open a window after the mainWindow and activate it

开发者 https://www.devze.com 2023-02-11 06:56 出处:网络
In m开发者_StackOverflow社区y application is required the user to select an item from a list before continues uses the application.

In m开发者_StackOverflow社区y application is required the user to select an item from a list before continues uses the application.

To do this, I have a window with the desired items and I display it when the MainWindow displays.

public MainWindow() 
{
    InitializeComponent();
    var itemsWindow = new ItemsWindow();
    itemsWindow.Show();
}

The problem is that the window opens in background. How can I open the window in foreground?

The preferable would be to open the itemsWindow on applications start up and onClose event of itemsWindow to display the mainWindow, but I think this approach is far away from my knowledge. Nevertheless, I would appreciate it if someone could post something for how to achieve this.

Thanks


Use ShowDialog() method instead. That way, you won't have to worry about activating that window and user won't be able to interact with MainWindow until ItemsWindow has been closed.

Example:

var itemsWindow = new ItemsWindow();
itemsWindow.ShowDialog();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号