Make child window always on top of all windows

淺唱寂寞╮ 提交于 2019-12-11 00:39:54

问题


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?


回答1:


window.TopMost = true;



回答2:


just try with

window.Owner=this


来源:https://stackoverflow.com/questions/3838944/make-child-window-always-on-top-of-all-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!