Moving to next control on button click in WPF [duplicate] - wpf

This question already has answers here:
Moving to next control on Enter keypress in WPF
(7 answers)
Closed 8 years ago.
I want to move to the next control when I click the button instead of the Tab key in a WPF MVVM application. How can I achieve this?

You question seems not clear. But to set focus on a control you can do this
controlId.focus()
However, check out Moving to next control on Enter keypress in WPF, it could be of help too

Related

Drag and drop on editable combobox [duplicate]

This question already has answers here:
Wpf: Drag And Drop To A Textbox
(4 answers)
Closed 1 year ago.
In WPF, I need to drop a file to a combobox which is editable.
I can drop on the arrow and on the border of the combobox, but not directly on the main white part (the textbox part) I have tried to add handler for the sub-textbox, but no luck.
Here is the code I use for that (VB .net, I know...)
CType(Combo_Fichier1.Template.FindName("PART_EditableTextBox", Combo_Fichier1), TextBox).AllowDrop = True
AddHandler CType(Combo_Fichier1.Template.FindName("PART_EditableTextBox", Combo_Fichier1), TextBox).Drop, AddressOf Combo_Fichier1_Drop
AddHandler CType(Combo_Fichier1.Template.FindName("PART_EditableTextBox", Combo_Fichier1), TextBox).DragEnter, AddressOf Function_DragEnter
AddHandler CType(Combo_Fichier1.Template.FindName("PART_EditableTextBox", Combo_Fichier1), TextBox).DragOver, AddressOf Function_DragEnter
My DragEnter function change the drag and drop effect to copy (working on the border and on the arrow) and my drop function simply set the text of the combobox with the name and path of the file. It's a sort of file selector with memory.
The problem likely occurs because the TextBox control supports the drag and drop of strings out of the box. Because of that it ignores other objects.
It is possible to use the PreviewDragOver event to avoid this problem as described in this thread: https://stackoverflow.com/a/23150582/12797700

Delete Close button in WPF window [duplicate]

This question already has answers here:
How to hide close button in WPF window?
(23 answers)
Closed 9 years ago.
I am trying to delete "X"/ Close button on the right side of the WPF window. I tried researching a lot about it on internet and came across 2 methods of doing it.
Completely removing the title bar by using GetWindowLong and SetWindowLong using solution posted in this post.
How to hide close button in WPF window?
Problem - this method removes the complete System menu(buttons of right side + Icon on left side) and I don't want ICON to disappear.
Used GetSystemMenu,RemoveMenu
Problem - this method only disables/grays out the X button although it keeps the ICON but doesn't remove the X button.
Can someone please help me with this issue?
You need to create your own chrome, add the buttons for minimize, maximize, close, etc, and disable the close button. You need to provide code for all the other functions, such as dragging area, context menus for moving, etc. Not too much and it will get you exactly what you want.

WPF + XNA: WPF TextBox not handling key inputs

I'm trying to integrate XNA into a WPF window, using the WindowsFormsHost control in the WPF window. I've got a very strange problem that whenever XNA is running, my keyboard input into my WPF window controls don't work. More weirdly, this is happening not for all keys. It happens for all the letters and numbers, but, for example, backspace or delete key work. I first thought this was due to XNA hooking up to the keyboard input and handling all the key presses, and the events weren't being routed to my WPF window. But weirdly, they DO get handled by the OnKeyDown. I've created a custom TextBox class that derives from normal TextBox, overrided the OnKeyDown, put a breakpoint in, and it worked. The debugger stepped on the breakpoint. So I was wrong: XNA wasn't blocking the key events from reaching the WPF window (or its controls), my TextBox IS getting the correct keyboard event, but it just doesn't work. I press 'A' on my keyboard, OnKeyDown gets called, but it doesn't append 'A' into the textbox. The backspace key, on the other hand, works normally. I copy paste some text into the field using mouse right click, and I click on the middle of the text (arrows don't work too), I can delete the text by pressing backspace, but I can't type anything.
What can be the reason? I am not really good with WPF's input handling, but normally, if my TextBox DOES get the OnKeyDown event (with the right argument), it should append the letter that I've pressed. As soon as I end the XNA game, things start behaving correctly. What can be the reason for the controls behaving abnormally?
Someone else has ran into the same problem here: http://forums.create.msdn.com/forums/p/98145/584961.aspx and they've found the solution to the problem (they've also linked to this question, too)
The interoperability of XNA and WPF needs a little tweak:
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(this);
This code should be pasted to the constructor of the WPF window that will be hosting the XNA content. I've pasted it to the constructr after InitializeComponent() and it worked.

WPF autocomplete Combobox [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
IsEditable property of WPF combobox
I have heard that autocomplete does not work (out of box) in WPF combobox but when I type characters in teh WPF combo, it matches existing items of combo and automatically completes it. Isn't this autocomplete?
Am I missing a point?
The WPF combobox does match existing values as you type, but...
Generally when people refer to an autocomplete combobox they mean a combobox that makes a backend query of some sort that will populate the dropdown with new values that match the criteria as the user types.

Windows Forms YesNo Message Box - Buttons Text [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to change button text for Yes & No buttons on MessageBox.Show Dialog?
In a Windows Forms application I have a MessageBox with YesNo buttons. I want to change the text on the buttons (from "Yes", "No" to something custom).
If I were you I'd create my own MessageBox dialog. It's not that hard and I'm sure you'd be able to do this faster than hacking the standard MessageBox.
Your only possible "customization" with the winforms MessageBox is to use the MessageBoxButton enumeration when creating the MessageBox.
It is fairly limited, so looking for a third party message box or creating your own dialog box may be a better choice.

Resources