Hi,
I need to hide a RadWindow completely and have tried multiple ways but they do not give the expected result. In fact, I have tried minimizing the window and hiding the icon from the taskbar (but I haven't found such a method in the documentation), or setting the visibility to Hidden but none of those completely hide the Window. How is it possible to hide a window, other than by closing it?
Kind regards,
Alexandre
7 Answers, 1 is accepted
The easiest approach to acheive your requirement might be setting the Width and Height of the window to 0. I've attached a small example showing this approach. Can you check it out and let me know if it helps?
Regards,
Martin Ivanov
Progress Telerik

Hello,
I have solved the problem by using this:
1.
var window = Window.GetWindow(form);
2.
window.ShowInTaskBar =
false
;
3.
window.WindowState = WindowState.Minimized;
Thank you nonetheless for the solution you have suggested.
Regards,
Alexandre
To achieve this you can override the ShouldShowInTaskSwitcher of RadWindow and return false.
public partial class MainWindow : RadWindow
{
protected override bool ShouldShowInTaskSwitcher()
{
return false;
}
}

I've come accross this thread as I changed my window to a RadWindow and now the Hide() method no longer works. I downloaded your sample show-hide-window.zip which doesn't do as described. There is a main window which is not a RadWindow, with no other files that open or close the window. There isn't anywhere in the project that hides the window.
Also, is this the only way? When I tried it in my solution, the window went visibley smaller so there was just the title bar left, then just showed that small bit blurred out. This is not at all professional looking. I also used the Visibility to collapsed which didn't do anything.
RadWindowInteropHelper.SetShowInTaskbar(this, false);
Height = 0;
Width = 0;
Visibility = Visibility.Collapsed;
Please advise,
Many thanks.

Hello Avrohom,
It seems that I've attached the wrong project. Anyway, here is another approach that is a bit more convenient. Basically, you can get the host Window control and call its Hide() method. Here is an example in code:
private void HideWindow()
{
var hostWindow = this.radWindow.ParentOfType<Window>();
RadWindowInteropHelper.SetShowInTaskbar(this, false);
hostWindow.Hide();
}
I also attached a sample project showing this approach. I hope it helps.
Regards,
Martin Ivanov
Progress Telerik

Hi Martin Ivanov,
This works perfectly. In my case I was trying to hide the window that was calling the Hide method, so I could replace:
var hostWindow = this.radWindow.ParentOfType<
Window
>();
with:
var hostWindow = this.ParentOfType<
Window
>();
Thank you.
P.s. Just out of interest, why does all the code from Telerik use
this.radWindow.ParentOfType
rather than just
radWindow.ParentOfType
??
Hello Avrohom,
It is good to hear that my suggestion was helpful.
As for why the code snippets use "this.radWindow" instead of "this", that is because RadWindow us often used in code. Something like this:
private RadWindow radWindow = new RadWindow();
private void ShowRadWindow()
{
this.radWindow.Content = new MyUserControl();
this.radWindow.Show():
}
Regards,
Martin Ivanov
Progress Telerik