Bringing Window to front in WPF
Recently I was working on WPF application where the Window would be minimized to tray and when user click’s the tray icon, the window has to show up in front of other windows.
I tried lot many variants and had trouble with Windows 7 and Windows 2008 R2. The following code finally worked for me.
Note: This code was present in the Window which was supposed to be controlled. If required replace “this” with actual reference of the Window.
if (!this.IsVisible) { this.Show(); } this.WindowState = WindowState.Normal; this.Activate(); this.Topmost = true; this.Topmost = false; this.Focus();
Manas
March 19, 2018 - 12:28 PM
Thanks a lot. It works.
Raj
July 7, 2018 - 2:26 AM
It worked for me too. thanks !
Ashu
December 17, 2019 - 1:22 PM
Thanks it works.