I am trying to get a control i can click on, press any keys (except tab) and have it take in the input. I tried using this and had a problem with the arrow keys changing the focus. That question is here.
The textbox seems to work but i dont like how it blinks. As in the line that shows where you next letter will be placed. How do i fix this?
Blinking is a system wide option. Check this out.
If you create a UserControl based on the standard textbox you can use [Control::IsInputKey][1] to override default behaviour which causes the control to lose focus.
Related
I'm using the WPF extended toolkit DecimalUpDown control. I allow the user to change the Increment property of this control in a couple of ways. I would like to be able to give them feedback as to which digit will change when the up/down buttons are clicked (or the mouse wheel is scrolled). I would like to change some property of the digit that would increment. Changing the color, the background, underlining, bolding, pretty much anything would be acceptable but I get the feeling there is no native support for this, but maybe I'm missing something.
It doesn't appear to be possible, but I ended up just using tooltips to help. If the user hovers over the control it shows the current increment. If the tooltip is showing and any of the methods for modifying the increment are used, the tooltip will update in real time with the current increment. Not perfect but seems to help.
Title pretty much explains it all really. I need to know how to automatically jump to the next element (the element that would get focus if the user presses the "Tab" key), whatever that may be, in the KeyDown event of a Silverlight TextBox. My TextBoxes are generated dynamically so I can't, for example, manually code TextBox1 to set focus on TextBox2 on keydown etc. Any help would be greatly appreciated
I don't believe there is an easy way to accomplish this. The only method I know of is to use the VisualTreeHelper and get all the elements and then loop through them by their tab stop values.
If your textboxes are generated dynamically you could use a Behavior to set their tab stop properties pretty easily which would be a much better solution. Or just set it when you create them.
I'm trying to remove caret blinking from a textbox after the input is done. I've tried focusing another control programmatically and setting IsReadOnlyCaretVisible=false and IsReadOnly on mouseleave event but nothing helps. What should I do? The caret still remains there whatever I do...
That's very strange. The caret should go away when the focus changes, eg when you click out of the textbox. You can't use the old fashioned "HideCaret" WINAPI function, since it's not a standard Windows control - it's WPF.
This question addresses the OPPOSITE of your problem, since your problem isn't supposed to even happen, and the solution was a very simple line of code. Perhaps if you flip the logic around, or find out if your code is already doing this and disable that part - you can get the result you're looking for: WPF Textbox persist visible caret
Also, if you're using a recent version of WPF, you can probably reassign the brush that the caret uses.
I believe the cursor over a textbox is called a caretbrush.
There are times application is run without a keyboard/ mouse (eg: Kiosk), so I will put up a virtual keyboard for the user.
The virtual keyboard appends to the textbox programmatically.
When I focus on the textbox, irregardless of have any text in it, the caretbrush will always be at the leftmost position.
Is there anyway I can control the position of it?
If unable to do it, guess I just hide the caret brush, otherwise it looks abit confusing especially when u are at the 3rd character but the caretbrush shows on the 1st character.
I found the answer already.
txt1.SelectionStart=txt1.text.length
but txt1.SelectionStart=txt1.text.length-1 is only correct
I have a WPF Textbox, that I want to check that the text value is correct before I allow it to lose keyboard/focus.
I have tried setting e.Handled in the InputBox_LostFocus & InputBox_LostKeyboardFocus events, but it doesnt seem to be achieving what I want.
Any suggestions on how I can lock focus to a Textbox?
The best way to do this is to handle the PreviewLostKeyboardFocus event which is fired while the event is tunneling down to your textbox. Set handle to true and nothing else will receive the notification (meaning focus will not be transfered away from your textbox). Hope this helps.
You can call Mouse.Capture on a UIElement. This will then give you every mouse event that hapens whether on the element or not. but its tricky to use. You can capture the mouse on your text box and register for lost capture events, when you lose capture you can recapture. you have to watch out for strange behaviors. Generally its bad practice (I think) to not allow a user to move off a field. what is better is to allow them to do whatever they want, but disable the button that they push after entering data until all fields are valid (or something similar)
Here are some links
other SO question
msdn sample code
the combo box uses mouse capture to tell if the user has clicked elsewhere in the app to close the combo box if its open if you click on another control (or outside the window)
I dont know if this technique will stop you tabbing off the element. there are two kinds of focus in a wpf app. You have logical focus and keyboard focus. Multiple elements can have logical focus at once (each within a focus scope). think for example a textbox can have logical focus while you are clicking a menu (which has logical focus as well). Keyboard focus can only be in one place at a time. You are going to make a lot of work for yourself. I would seriously consider if you are doing your interaction in the right way. You could spend days getting this interaction correct. If you stop your textbox losing focus, what happens if the user clicks the close button?
heres the msdn article on focus