This is a migrated thread and some comments may be shown as answers.
Commit edit on lost focus
3 Answers 72 Views
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 04 Nov 2011, 11:07 PM
I'm using the GridView in a project and I have an issue that I'm hoping has an easy solution. See, my GridView is bound to an ObservableCollection and inserts are enabled. Elsewhere in my UX (on a completely different View, in fact) I have a Save button that will send the contents of the collection off to a web service for processing. The button and GridView have no knowledge of each other in this MVVM app.

The issue that I'm having, however, is that when a user inserts a new row, but doesn't press ENTER or ESC to cancel or commit then clicks on the Save button, the collection is in a half-baked state. My preferred behavior would be for the GridView to commit the row edit whenever the GridView clicks anywhere outside of the row being edited. Is that possible?

3 Answers, 1 is accepted

Sort by
0
Greg
Top achievements
Rank 1
answered on 07 Jul 2015, 09:39 PM

I also am having this problem. In an MVVM scenario with multiple user controls in a layout clicking a button in a user control different from the GridView does not cause the GridView to lose focus and commit the change.

 

Telerik - answer please!

0
Greg
Top achievements
Rank 1
answered on 07 Jul 2015, 10:28 PM

Answered my own question: Add:

FocusManager.IsFocusScope="False"

to all ContentControls on the page/window - this allows the contained controls to "share" focus and thus fires loss-of-focus events on their controls.

0
Geert
Top achievements
Rank 1
answered on 25 Jun 2020, 01:37 PM
I was experiencing the same problem but was able to fix it by doing the following:

gridview.CommitRowEdit(gridview.RowInEditMode);

When the button outside of the gridview control is clicked an event is fired wherein by using this line of code the row which is currently in edit mode is committed.
Asked by
Greg
Top achievements
Rank 1
Answers by
Greg
Top achievements
Rank 1
Geert
Top achievements
Rank 1
Share this question
or