focusmanager

Focus Textbox using FocusManager.FocusedElement issue

爱⌒轻易说出口 提交于 2019-12-05 15:30:19
I'm trying to set the keyboard focus to a textbox that is included in a stackpanel. When the IsEditMode becomes true i want the textbox to become, by default, focused. I've tried this code: <DataTemplate x:Key="LibraryItemTemplate"> <StackPanel Orientation="Vertical"> <StackPanel.Style> <Style TargetType="StackPanel"> <Style.Triggers> <DataTrigger Binding="{Binding IsEditMode}" Value="True"> <Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=TxtB}"/> </DataTrigger> </Style.Triggers> </Style> </StackPanel.Style> <TextBlock x:Name="TxtA" Text="A" /> <TextBox x:Name="TxtB"

Instable focus of WPF apps

瘦欲@ 提交于 2019-12-01 11:07:34
If I have problems with WPF, then it always concerns the Focus-Management. There are cases, my App loses totally focus so that another application gains the focus and my app goes in the background . This happens mainly if some windows in my app will be closed. Is this a known problem of WPF. Does someone else has similar problems? I already opened another thread to this, but no one could help, maybe it was a little to detailed. Therefore this here is the short version. UPDATE It seems that I have found a simple hack that helps prevent the behavior I describe in the other thread . If you have

How do you solve this LostFocus/LostKeyboardFocus issue?

喜欢而已 提交于 2019-11-30 09:00:51
Ok, I have a control that has an IsEditing property which for argument's sake has a default template that is normally a text block, but when IsEditing is true, it swaps in a textbox for in-place editing. Now when the control loses focus, if it's still editing, it's supposed to drop out of editing mode and swap back in the TextBlock template. Pretty straight forward, right? Think of the behavior of renaming a file in Windows Explorer or on your desktop (which is the same thing I know...) That's the behavior we want. The issue is you can't use the LostFocus event because when you switch to

Change focus to next component in JTable using TAB

北城余情 提交于 2019-11-29 13:32:05
JTable's default behavior is changing focus to next cell and I want to force it to move focus to next component (e.g. JTextField) on TAB key pressed. I overrided isCellEditable method of DefaultTableModel to always return false: public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } But it still doesn't change focus to next component! How should I make JTable change focus to next component instead of next cell? If you really want this, you need to change the default behavior of the tables action map. ActionMap am = table.getActionMap(); am.put("selectPreviousColumnCell"

How do you solve this LostFocus/LostKeyboardFocus issue?

a 夏天 提交于 2019-11-29 12:47:46
问题 Ok, I have a control that has an IsEditing property which for argument's sake has a default template that is normally a text block, but when IsEditing is true, it swaps in a textbox for in-place editing. Now when the control loses focus, if it's still editing, it's supposed to drop out of editing mode and swap back in the TextBlock template. Pretty straight forward, right? Think of the behavior of renaming a file in Windows Explorer or on your desktop (which is the same thing I know...) That

WPF FocusNavigationDirection, MoveFocus and Arrow keys

China☆狼群 提交于 2019-11-28 05:54:48
问题 I have a simple application (a grid with 6 buttons - 2 rows of 3 - on it for testing) and am handling left and right arrow keys as follows private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { FocusNavigationDirection focusDirection = new System.Windows.Input.FocusNavigationDirection(); switch (e.Key) { case Key.Left: focusDirection = System.Windows.Input.FocusNavigationDirection.Left; break; case Key.Right: focusDirection = System.Windows.Input.FocusNavigationDirection.Right;

Can't set focus to a child of UserControl

谁说我不能喝 提交于 2019-11-28 04:40:00
I have a UserControl which contains a TextBox . When my main window loads I want to set the focus to this textbox so I added Focusable="True" GotFocus="UC_GotFocus" to the UserControl s definition and FocusManager.FocusedElement="{Binding ElementName=login}" to my main windows definition. In the UC_GotFocus method i simply call .Focus() on the control i want to focus on but this doesn't work. All i need to do is have a TextBox in a UserControl receive focus when the application starts. Any help would be appreciated, thanks. eesh I recently fixed this problem for a login splash screen that is

Can't set focus to a child of UserControl

十年热恋 提交于 2019-11-27 05:25:47
问题 I have a UserControl which contains a TextBox . When my main window loads I want to set the focus to this textbox so I added Focusable="True" GotFocus="UC_GotFocus" to the UserControl s definition and FocusManager.FocusedElement="{Binding ElementName=login}" to my main windows definition. In the UC_GotFocus method i simply call .Focus() on the control i want to focus on but this doesn't work. All i need to do is have a TextBox in a UserControl receive focus when the application starts. Any