New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't select a cell in the DataGrid reliably #450
Comments
You are not alone. I wish I knew the "proper" way to insert then immediately edit a new item. I found that simply waiting 100 milliseconds after the insert wasn't always enough. I ended up putting the wait in a loop that attempts to select the new item after the wait, then confirms that the new item is selected. If not, the loop continues up to some reasonable maximum (5 times?). After the new item is successfully selected, then I call I admit this workaround is completely crazy. There's got to be a better way.
|
Hi @Encrypt0r , About your second issue with the focus of the NumericBox. Basically, the control is focused, however the TextBox inside it is not. In order to focus the TextBox when the row is created and is edited I can suggest you the following approach. First you can create a custom NumericBox. Once it gets the focus you can propagate the focus to the TextBox - that should only be done initially in order to prevent some unexpected behavior. In order to use that custom NumericBox a custom DataGridNumericalColumn should be created as well. Inside it the custom NumericBox editor could be se set as an editor type for the column and focusing should be working as desired. I have modified the sample project in order to demonstrate the described above approach - please, check it: I will leave the issue open for now. I believe that the DataGrid control could a little bit be improved at least with some API that could tell when the DataGrid is completely loaded and when it will be possible to perform different operations like BeginEdit or selection. Hope this helps. |
Description
When I add a row to the datagrid, I want to focus on the first editable cell of the row. This is the code I use for that:
I have two issues:
InvalidOperationException "Sequence contains no elements"
. Here is the full stack trace:Note: If I use
_items.Add(item);
without Task.Delay, it will alwasy throw the exception.Steps to Reproduce
Expected Behavior
The added row begins editing and the quantity column is focused.
Actual Behavior
Throws an exception if no Task.Delay is used and doesn't focus on the quantity column.
Basic Information
Screenshots
https://youtu.be/a_3j64aVf5A
Reproduction Link
DataGridBeginEditRepro.zip
The text was updated successfully, but these errors were encountered: