AvaloniaUI Datagrid focus back on editing control after error notification - datagrid

I have a simple datagridtextcolumn:
<DataGridTextColumn
Header="Departing Date"
Binding="{Binding DepartingDateString}"
/>
My model implements INotifyDataErrorInfo
I do get an error whenever the wrong data is input:
However, the focus is lost and would require a mouse input to focus back unto the editing textbox. Is there a way to get it automatically focused back or at least using a keyboard key?

Related

How to keep the software keyboard in Android from hiding after a TextBox loses focus in Uno Platform?

I have a TextBox and a Button. When the button is clicked, the TextBox loses focus and the keyboard hides. How do I keep the keyboard from hiding when the button is clicked?
I first thought to use AllowFocusOnInteraction, but this is not supported on Android at this time.
Although AllowFocusOnInteraction isn't implemented, Control.IsTabStop is. IsTabStop likewise prevents the control from receiving focus. Use IsTabStop instead.
Uno Platform is using the Android input behavior here, so when the input loses focus, the programmatic keyboard automatically disappears. However, if you want to show it again immediately, you can give it focus again from within the button Click handler.
XAML:
<TextBox x:Name="InputBox" />
<Button Click="TestClick">Test</Button>
C#:
private void TestClick(object sender, RoutedEventArgs e)
{
InputBox.Focus(FocusState.Programmatic);
}
The input pane starts disappearing, but is immediately requested again, so it is almost imperceptible.
You can also try to trigger the soft keyboard programmatically without having any TextBox in place, by writing platform-specific code. This SO question for example includes quite a few solutions for Android. In general, they utilize the INPUT_METHOD_SERVICE and call ShowSoftInput on it.

Xamarin Entry focus control with barcode reading

I lost my mind trying to make the focus change automatically between 3 entry field and an "OK" button!
I use a small android device that integrates a barcode reader. I set up the barcode reader to add a "enter key" when barcode is read. That call the OnEnterPressedCommand binded to my viewmodel, then I do some validation and send a message with messaging center to the view code-behind for the focus change.
When I use manually use the "enter" key on the virtual keyboard all work like expected. But when I scan the barcode (with the automatic enter) some focus on fields work, but some never got focus!
Does the virtual enter key work do not do the same thing that hitting adding a enter automatically??

Keyboard control of GUI dialogs - Should default button change with focus?

In GUI dialogs, most applications provide for keyboard control as follows:
Enter key - presses the default button. (Default is usually indicated with a bold button border.)
Esc key - presses the Cancel or close button.
Space key - presses widget that currently has keyboard focus.
Tab key - advances focus to next widget.
Question is, when keyboard focus is on a widget that is a button, should the default button be changed to be the one with focus?
I see some issues with this behavior:
The display noise of redrawing buttons to unbold the outline of original default button and rebold the button under focus as being new default.
The Space key is now somewhat redundant with Enter key.
There is no keyboard accelerator to get the normal default button now (Usually the OK button).
However, it seems the trend has been in this direction to change the default button with focus change to another button. What is the rationale for this departure from the early GUIs? It would seem to provide less functionality given there is no way to press the original default button. Did people find that the original model was too complicated for users to understand? I would think keyboard control of dialogs would be a task for advanced users who would have no trouble understanding the model and prefer to have accelerator for current button (Space) and original default button (Enter) at all times.
Note that Qt for one is supporting the change: QPushButton's autoDefault property is responsible for the behavior of changing the default button. By default its value is true. Therefore, you must take extra action to set it to false for all buttons, to prevent them from becoming the default button when focused.
This is not a "departure from the early GUIs", at least not if by "early GUIs", you mean Windows 1.0. The behavior that you describe has been this way since the beginning.
The focused button is always "pushed" when the Enter key is pressed. The default button is only triggered in the following two situations:
The default button has the focus (which it does by default), or
The focus is on a control that does not process Enter key presses (such as a static control, or a single-line textbox that does not have the ES_WANTRETURN style flag set).
The famous Win32 blogger Raymond Chen has a post explaining this behavior (focus specifically on the last two quoted paragraphs):
A dialog box maintains the concept of a "default button" (which is always a pushbutton). The default button is typically drawn with a distinctive look (a heavy outline or a different color) and indicates what action the dialog box will take when you hit Enter. Note that this is not the same as the control that has the focus.
For example, open the Run dialog from the Start menu. Observe that the OK button is the default button; it has a different look from the other buttons. But focus is on the edit control. Your typing goes to the edit control, until you hit Enter; the Enter activates the default button, which is OK.
As you tab through the dialog, observe what happens to the default button. When the dialog box moves focus to a pushbutton, that pushbutton becomes the new default button. But when the dialog box moves focus to something that isn't a pushbutton at all, the OK button resumes its position as the default button.
The dialog manager remebers which control was the default button when the dialog was initially created, and when it moves focus to something that isn't a button, it restores that original button as the default button.
The behavior that I would expect is:
If I press enter when the window just pop up, it should press the default button
If I press tab, I start navigating through the widgets. In this case there are two options:
2.1 I press enter - this event should be delivered to the focused widget. There's no need to change the default button - simply hand the event to the focused widget.
2.2 I press escape. In this case, everything should go back to the state after the window is created.
Notes:
I come from a mixed background - I don't know if I learned this in windows, linux or Mobile OSes! This is just how I expect things to work out.
I don't use the space key (didn't know it's functionality)

Combo Box in ActivityDesigner loses it's selection when the control is closed

first time posting here.. so go easy =)
I am trying to learn the Workflow model, and ended up creating my own activity. Below is the XAML for the combo box in question.
<ComboBox ItemsSource="{Binding Source={StaticResource PossibleValues}}" SelectedValue="{Binding Path=ModelItem.SelectedEvent, Converter={StaticResource LifeEventConverter}}"
I have the following property defined in my Code Activity:
Public Property SelectedEvent As LifeEvents
The code works, my problem is whenever I close and reopen visual studio the combo box does not keep the last selected item. The property does keep it's value, but it driving me nuts that I can't tell what item is selected just looking at my workflow.
Does anybody have any ideas?
Can't tell for sure what the problem is but for a start the normal way to define input arguments to an activity it by creating properties of type InArgument. Not sure if that will solve your problem though.
The first thing I would check is if selected value, or anything else, shows up in the XAML for SelectedEvent.

How to prevent clicking on a checkbox from firing the datagrid's selection_changed - Silverlight 3

I am currently using a Datagrid binding to a list of items in Silverlight 3. Each row has two checkboxes. Anyone please help me how to prevent the Datagrid from firing the Selection_Changed event each time I click on any checkbox? I have been stuck with this for some days, deadline is coming near.
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
<data:DataGridTemplateColumn Header="Track" SortMemberPath="IsTracked" CanUserResize="False" CanUserReorder="False">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<CheckBox
Tag="{Binding unitID, Mode=OneWay}"
Click="ShowB_Clicked" IsChecked="{Binding IsTracked, Mode=TwoWay}"></CheckBox>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
</data:DataGrid.Columns>
When I click on either the checkbox, the dgList_SelectionChanged of the Datagrid is fired and the SelectedIndex/Item also changed to the row that contains the clicked checkbox. What I want is not change the SelectedItem, in other word not fire dgList_SelectionChanged, of the datagrid.
Please help.
Thanks alot in advance.
Middlevn
Having a similar issue, starting to contemplate putting a see-through image over the checkbox to prevent the click, then use the cell changed event to get the checkbox value, then on current cell change set the current cell to something else.
I can't wait for better support for html5 so I can dump this MS garbage

Resources