Visual studio editor window stealing focus - wpf

I'm working on a visual studio extension. It has a command that opens up a WPF window that has a single item which is a textbox. If you type in the textbox you can see the text show up, but if you hit a key combination such as ctrl+a the visual studio editor which is behind my window captures the key press and selects the content from the editor instead of my window. If I click on something like the solution explorer and go back to my window though ctrl+a will work fine. It seems that I only have the issue while the editor has focus. Any ideas what I can do to get around this?

Open your WPF window as modal using ShowDialog or create a Visual Studio tool window to host your textbox, if you want a modeless window.

Related

Windows Form Toolbox is empty

In my Visual Studio 2015, Windows Forms Tool Box (where we have controls like Text box, button etc) is not showing up.
I tried checking all the check marks in Views->ToolBars, but no use.
Please help.
Thanks,
Make sure you have opened a Windows Forms project.
Open View menu and check Toolbox or use Ctrl+Alt+X shortcut and you will see the toolbox.
The toolbox will fill with controls when you open a Form or UserControl in design view.

How to solve Visual C++ window form disappearance?

I have a visual c++ program which has a few window forms. It does not have any error and can be built successfully. Today I want to add another textbox and a button to one of the form, but I cannot find out my form design window. I see the Form1.h, Form1.resX and my other stuff. Once again, I can built it and the program does not have any error, but the form design window disappear. Please help.
For VS2008
Click View->Resource View or in the Solution Explorer click the Resource View tab
Under "App.rc" click Dialog, you can view your form there

What is the hokey to switch from XAML tab to Design tab in Visual Studio 2010

I want to know if there's a shortcut/hotkey to switch between XAML to the designer. Doing WPF I like to code XAML full screen then check the design full screen. I've looked up Google, without success.
Something similar to the F7 shortcut to switch between code/design in winform probly exist for wpf.
You can switch from XAML view to Designer view using SHIFT + F7 hotkey and switch back using navigation.Back (Ctrl + -).
This worked for me.
Open your XAML file in the main view and keep it in the Designer View.
Right click the same XAML file in Solution Explorer and use 'Open With' option.
Select the editor you are most comfortable with from the list of editors.
This opens the XAML mark up code in a separate window.
You can now type the XAML mark up in one window and when you save the changes are reflected in the designer view (open in your main window).
You can switch between them using regular short cut keys to switch between windows in Visual Studio. You can even drag them to different monitors and see them side by side.

Foxpro hosted Wpf window return focus to foxpro when Tab is pressed

I have a Visual FoxPro 9 application from which I call a wpf window using COM interop. When TAB is pressed for the first time the focus goes back to the FoxPro window. If I come back to the wpf window this happens again until the third time I do it, and then the focus works normally. This occurs using the mouse or Alt+Tab to go back to the wpf window. It happens whether there is a focused element (textbox, datepicker,...) or not.
I have tried to capture the PreviewKeyDown event of the window, but it seems that it happens before it can capture it. I have tested the wpf window in a wpf application and it works ok.
The C Sharp class is like:
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ProgId("SBN.WPF.Com")]
[ComVisible(true)]
public class WpfFoxPro
{
and the FoxPro calls are like:
oDll = Createobjectex("SBN.WPF.Com", "", "")
oDll.VOpenWPFWindow()
I'm using Visual Studio 2010 and .Net 4.0 and I'm running out of ideas. Does any one know something about this?
Might sound stupid, but could you disable the VFP windows whilst the WPF one is active? It's not a solution, but based on 10 years of working with VFP, sometimes you just have to stop bashing your head against the brick wall and go for the kludge. ;)

WPF modeless dialog renders textbox uneditable

A WPF form that I launch from a WinForms window shows up with all textboxes as uneditable when it's launched as a modeless dialog. It works well when it's a modal window. I'm still able to type spaces or paste text. But regular typing doesn't work. I'm using 3.5 with SP1. Would anybody know how to resolve this?
You need to make sure to call ElementHost.EnableModelessKeyboardInterop for your WPF Window. This hooks up the WPF message loop to allow keyboard input.

Resources