I have a winform dashboard which hosts some WPF dialogs. When I select a row in the winform ListView and hit Enter key, OnItemActivate is called which launches a WPF dialog. However, the WPF dialog appears and then disappears immediately because the default button “cancel” is hit. It seems that the Enter key is triggered twice, one for launching the WPF dialog, the other for hitting cancel button. We don’t want the WPF dialog to be canceled by the Enter key hitting.
According to the stack trace, it looks like that WPF and Winform handle the enter key separately. The WPF does not know that the enter key has been handled by the Winform ListView. Is this by design in Winform and WPF interop?
To make the enter key not close the WPF dialog, we have to change the focus from the cancel button to another control (e.g. a textblock). Is there a better way to fix/around this issue?
As Rick suggested in the comments, try calling Application.DoEvents() before opening the WPF dialog.
Related
I have an application where on the click of a button in winforms I launch a WPF dialog using ShowDialog().
The issue what i am facing is related to key strokes. when i press a key after launching the WPF dialog, the key stroke is not handled at the WPF dialog level, instead it passes on to the winform from where dialog was launched and as such the desired operation what i have inside the keyevent handler in WPFis escaped. How do i stop this? I tried using dispatchHelper but it did not work out.
I'm currently designing a workflow that displays user controls on a winforms form then waits for the user to click a button on the user control just displayed so that it can capture data the user entered. I'm having difficulty finding an activity? (is that the right word?) that sits and waits for a click event to occur on the button of the item.
Does anybody have an idea about how to do this?
Thanks,
I've started using the XCEED MessageBox recently, which uses custom chromes (<-I think that's their name) for the title bar, and it seems that there is no handling for the case when a dialog window (or modal dialog in Win32 terms) needs to flash in response to the user trying to click on the (disabled) parent window.
The flashing border animation is usefull to notify a user that he must respond to a dialog before continuing and to give a hint on which dialog window is that.
Is there a way to get notified when a window needs to perform the flash animation in WPF or set XAML triggers for it?
For my full screen WPF application, I need to show up the Windows 7 onscreen keyboard, if a user sets the focus on a textfield.
There's no hard keyboard for the panel, just a mouse device to interact with it. In this case I need a onscreen keyboard to fill up the textfields.
The WPF-application is written in C# .Net on the .Net Framework 4.0 Client profile.
Thanks for reply
Andi
You can wire up following code to TextBox's GotKeyboardFocus or GotFocus event
Process.Start("systempath..\\osk.exe");
My WPF app has a window with various text boxes and a WebBrowser control.
The WebBrower control is used to show a web site (I doesn't own) and then a Login button in the WPF window fills the fields in the site from the text boxes.
The problem is that the web site calls focus() method on one of its input fields on load, and that still the focus from the text box in my WPF window. I want the focus to be on the WPF window field and not in the web page within the WebBrowser control.
I tryed calling MyTextBox.Focus() in the WebBrowser's LoadCompleted event, but to no avail. Setting the WebBrowser's IsEnabled or even Visibility properties didn't help either.
Does anyone have an idea how I can overcome this and move the focus to the WPF control instead of the web page input field?
Don't think you can extend the control site to add IProtectFocus to the site. Try interop the Windows Forms version of the webbrowser control and override the CreateWebBrowserSiteBase method to provide your own control site.