private void EditClick(object sender, RoutedEventArgs e) { if (editor == null) { editor = new CodeEditor(); editor.DataContext = this.DataContext; } else { // Hide and show will brind the window on top editor.Hide(); } editor.Show(); }