Hi,
I'm using RadDocking.GetFloatingWindowState(myRadDocumentPane) method on my floating documentPane. I have maximzied floating window by double clicking on its header, and then checked still this method returns "Normal state" result.
I need to find out if my floating window is in maximized state or not.
Thanks,
Tayyaba
9 Answers, 1 is accepted
In order to check whether a RadDocumentPane is in a maximized ToolWindow, you can check its WindowState property. You can find the ToolWindow that the pane is hosted in with the ParentOfType extension method. Here is how that would look:
var toolWindow =
this
.docPane.ParentOfType<ToolWindow>();
if
(toolWindow !=
null
)
{
var state = toolWindow.WindowState;
}
Please note that "this.docPane" refers to the RadDocumentPane instance that you want to check.
Hope you find this helpful.
Regards,
Vladimir Stoyanov
Progress Telerik
Hi Vladimir,
Thank you for helping me out, it worked.
But I also wanted to know how can I maximize my floating RadDocumentPane programmatically?
Thanks,
You should be able to set the window state in a similar manner:
var toolWindow =
this
.docPane.ParentOfType<ToolWindow>();
if
(toolWindow !=
null
)
{
toolWindow.WindowState = WindowState.Maximized;
}
Please give this a try and let me know if it works for you.
Regards,
Vladimir Stoyanov
Progress Telerik
Hi Vladimir
I have already tried the exact same thing, but it didn't work.
Regards,
Tayyaba
I am attaching a sample project demonstrating the approach I suggested. May I ask you to check it out and see how it differs from the setup at your end?
Should you need any further assistance, can you share what you are doing differently on your side?
Regards,
Vladimir Stoyanov
Progress Telerik
Hi Vladimir,
Your solution is working perfectly fine, and i've also found out why this same code isn't working on my side.
Actually I want to maximize my floating window whenever the main window is restored from minimized state, i've tried to do this same thing in your sample project as well, but now it is not working in that too. I think it is not working because the code gets executed while the window is still in minimized state.
I'm attaching the MainWindow.xaml.cs file which I have modified for the same project.
Please let me know, what can be done to make this scenario work for me.
Thanks.
Tayyaba
I was having some issue with attaching the project and file.
Here's the MianWindow.xaml.cs file code i missed to attached in my previous reply.
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.StateChanged += MainWindow_StateChanged;
}
private void MainWindow_StateChanged(object sender, System.EventArgs e)
{
if (this.WindowState == WindowState.Maximized || this.WindowState == WindowState.Normal)
{
var toolWindow = this.docPane.ParentOfType<
ToolWindow
>();
if (toolWindow != null)
{
toolWindow.WindowState = WindowState.Maximized;
}
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var toolWindow = this.docPane.ParentOfType<
ToolWindow
>();
if(toolWindow != null)
{
toolWindow.WindowState = WindowState.Maximized;
}
}
}
Thank you for the provided code snippet. Our forum system allows adding only image files. If you want to send us a .zip file with the project that demonstrates the issue you can open a new support ticket from your telerik.com account.
What I can suggest you in your case is to delay the setting of the WindowState property of the ToolWindow. Check the following code snippet.
private
void
Window_StateChanged(
object
sender, System.EventArgs e)
{
if
(
this
.WindowState == WindowState.Maximized ||
this
.WindowState == WindowState.Normal)
{
var toolWindow =
this
.docPane.ParentOfType<ToolWindow>();
if
(toolWindow !=
null
)
{
Dispatcher.BeginInvoke((Action)(() =>
{
toolWindow.WindowState = WindowState.Maximized;
}));
}
}
}
Regards,
Dinko
Progress Telerik
Hi Dinko,
Thank you so much for helping me out, it worked perfectly.
Regards,
Tayyaba