Make child window always on top of all windows

2019-07-17 02:07发布

I'm writing in wpf. In my viewModel I have a command that opens new window. However sometimes this child window is placed under the parent window. (if for instance I work in my application, then open browser and want to return to my application). Window is opened as follows:

MyViewModel vm = new MyViewModel(oper);
Mywindow window = new MyWindow();
//Initialize viewModel and set window.DataContext to this viewModel
CWPFWindowWithViewModelHelper<IWindowWithViewModel>.InitializeViewModel(window, vm);
window.ShowDialog();

I want this child window to be always visible when opened. How can I do this?

2条回答
该账号已被封号
2楼-- · 2019-07-17 02:31
window.TopMost = true;
查看更多
该账号已被封号
3楼-- · 2019-07-17 02:39

just try with

window.Owner=this
查看更多
登录 后发表回答