I've had a look, but can't see anything about other people having this particular issue.
We have a WPF library that contains a RadWindow with a textbox, requiring user input.
We then have a WinForms application that creates and show this RadWindow.
When we try to type in the textbox, nothing happens.
If we use a regular WPF window for the dialog, then we can use the ElementHost.EnableModelessKeyboardInterop() function, which makes everything work as expected. However, the RadWindow isn't actually a window, so we can't use this method.
So how do we resolve this issue?
Thanks
Jason
We have a WPF library that contains a RadWindow with a textbox, requiring user input.
We then have a WinForms application that creates and show this RadWindow.
When we try to type in the textbox, nothing happens.
If we use a regular WPF window for the dialog, then we can use the ElementHost.EnableModelessKeyboardInterop() function, which makes everything work as expected. However, the RadWindow isn't actually a window, so we can't use this method.
So how do we resolve this issue?
Thanks
Jason
8 Answers, 1 is accepted
0
cmasdev
Top achievements
Rank 2
answered on 14 Jan 2015, 11:53 AM
Have you tried this:
Hope it helps in any way.
Regards.
1.
yourRadWindow.Owner =
this
;
Hope it helps in any way.
Regards.
0
Jason
Top achievements
Rank 1
answered on 14 Jan 2015, 02:02 PM
What type are you expecting this to be?
For a RadWindow, the Owner needs to be a ContentControl. If this is the mainform, then the type is a Windows.Forms, which doesn't work as a RadWindow owner.
For a RadWindow, the Owner needs to be a ContentControl. If this is the mainform, then the type is a Windows.Forms, which doesn't work as a RadWindow owner.
0
Accepted
Hello Jason,
RadWindow is hosted in native WPF Window, so you would need to get its host in order enable the keyboard. This should be done after RadWindow is loaded - so you can hook to the Loaded event of get the parent WPF Window as shown below:
Hope this will work for you.
Regards,
Kalin
Telerik
RadWindow is hosted in native WPF Window, so you would need to get its host in order enable the keyboard. This should be done after RadWindow is loaded - so you can hook to the Loaded event of get the parent WPF Window as shown below:
void
radWind_Loaded(
object
sender, RoutedEventArgs e)
{
var radWindow = sender
as
RadWindow;
var window = Window.GetWindow(radWindow);
ElementHost.EnableModelessKeyboardInterop(window);
}
Hope this will work for you.
Regards,
Kalin
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Jason
Top achievements
Rank 1
answered on 15 Jan 2015, 01:34 PM
Perfect. And something that I'm sure I can use elsewhere.
Thanks
Thanks
0
Jason
Top achievements
Rank 1
answered on 10 Mar 2015, 12:36 PM
I have a secondary problem relating to this. I am attempting to set the owner of the dialog to the main WinForm, using code similar to
var wpfWindow = Window.GetWindow(lclDlg);
if (wpfWindow != null)
{
var helper = new WindowInteropHelper(wpfWindow) { Owner = ownerFrm.Handle };
}
I have this in the dialog loaded event, since that's when GetWindow actually works. However, the .NET framework then complains that you can't set the owner of a dialog once it's already been shown.
Any solution?
var wpfWindow = Window.GetWindow(lclDlg);
if (wpfWindow != null)
{
var helper = new WindowInteropHelper(wpfWindow) { Owner = ownerFrm.Handle };
}
I have this in the dialog loaded event, since that's when GetWindow actually works. However, the .NET framework then complains that you can't set the owner of a dialog once it's already been shown.
Any solution?
0
cmasdev
Top achievements
Rank 2
answered on 10 Mar 2015, 02:40 PM
Hi Jason, I think that your snippet must be something like this:
Hope it helps.
Regards.
//Win32 HWND
var wpfWindow = Window.GetWindow(lclDlg);
//getting you actual window
if
(wpfWindow !=
null
)
{
var helper =
new
WindowInteropHelper(wpfWindow);
helper.Owner = wpfWindow.Handle;
//get your Win32 HWND
wpfWindow.ShowDialog();
}
//WPF directly
var wpfWindow = Window.GetWindow(YOUR DESIRED WINDOW);
if
(wpfWindow !=
null
)
{
wpfWindow.Owner = App.Current.MainWindow;
wpfWindow.ShowDialog();
}
Hope it helps.
Regards.
0
Jason
Top achievements
Rank 1
answered on 10 Mar 2015, 03:24 PM
Unfortunately, that doesn't help the Win32 situation.
Window.GetWindow doesn't return anything until you've shown the dialog (from what I can tell), so you can't set the owner. WPF doesn't matter, since you can set a WPF parent on a WPF RadWindow before it's created
Window.GetWindow doesn't return anything until you've shown the dialog (from what I can tell), so you can't set the owner. WPF doesn't matter, since you can set a WPF parent on a WPF RadWindow before it's created
0
Hello Jason,
Unfortunately you it is not possible to set the owner after the dialog is already shown. However if you display RadWindow using the Show() method you will be able to set it on Loaded.
I hope not using dialog Window will be suitable for you.
Regards,
Kalin
Telerik
Unfortunately you it is not possible to set the owner after the dialog is already shown. However if you display RadWindow using the Show() method you will be able to set it on Loaded.
I hope not using dialog Window will be suitable for you.
Regards,
Kalin
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.