I want my window to be on top of all other windows in my application only. If I set the TopMost property of a window, it becomes on top of all windows of al
Instead you can use a Popup that will be TopMost always, decorate it similar to a Window and to attach it completely with your Application handle the LocationChanged event of your main Window and set IsOpen property of Popup to false.
I hope you want something like this:
Window1 window;
private void Button_Click(object sender, RoutedEventArgs e)
{
window = new Window1();
window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
window.Topmost = true;
this.LocationChanged+=OnLocationchanged;
window.Show();
}
private void OnLocationchanged(object sender, EventArgs e)
{
if(window!=null)
window.Close();
}
Hope it helps!!!