This is a migrated thread and some comments may be shown as answers.

Hide RadWindow

7 Answers 651 Views
Window
This is a migrated thread and some comments may be shown as answers.
Alexandre
Top achievements
Rank 1
Alexandre asked on 25 Dec 2018, 07:59 PM

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

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 26 Dec 2018, 10:34 AM
Hello Alexandre,

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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
1
Alexandre
Top achievements
Rank 1
answered on 27 Dec 2018, 09:59 AM

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

Valentin
Top achievements
Rank 1
Iron
Iron
commented on 12 Apr 2023, 08:56 AM

Hello, to complete this approach, is there any way to hide the window from the alt+tab menu? Thanks.
Martin Ivanov
Telerik team
commented on 12 Apr 2023, 11:27 AM

To achieve this you can override the ShouldShowInTaskSwitcher of RadWindow and return false.

public partial class MainWindow : RadWindow
{
	protected override bool ShouldShowInTaskSwitcher()
	{
		return false;
	}
}

0
Avrohom Yisroel
Top achievements
Rank 1
answered on 09 Sep 2019, 07:20 PM

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.

0
Avrohom Yisroel
Top achievements
Rank 1
answered on 09 Sep 2019, 07:22 PM
Whoops, forgot to add the screenshot I took to show.
0
Martin Ivanov
Telerik team
answered on 11 Sep 2019, 01:52 PM

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Avrohom Yisroel
Top achievements
Rank 1
answered on 17 Sep 2019, 07:27 PM

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

??

0
Martin Ivanov
Telerik team
answered on 18 Sep 2019, 07:56 AM

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Window
Asked by
Alexandre
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Alexandre
Top achievements
Rank 1
Avrohom Yisroel
Top achievements
Rank 1
Share this question
or