Dec 19, 2011 at 1:48 PM
Edited Dec 19, 2011 at 2:21 PM
Ah! Good idea! A small problem is that I would have to create something else to focus - my data window has only a TextBox at present.
I have fixed it this way (it seems to work but it's not yet fully tested). You may like to bake something like this into Catel. It handles the binding update without having to change focus, which would be an issue if the default button did not end up closing
- Add to the catel:DataWindow statement in the XAML of the view:
- Add the following code to the view model:
private System.Windows.Data.BindingGroup fixEnterBindingGroup;
public System.Windows.Data.BindingGroup FixEnterBindingGroup
if (fixEnterBindingGroup == null)
fixEnterBindingGroup = new System.Windows.Data.BindingGroup();
fixEnterBindingGroup.Name = "FixEnterBindingGroup";
- Add the following code at the beginning of the Save override in the ViewModel:
----------------- EDIT -----------------
On further testing I see that my fix doesn't work. I think the BindingGroup is being created too soon; it probably needs to be created in response to the View's Loaded event. I'll keep working on it ...
----------------- EDIT 2 ---------------
Ok, I was wrong. The BindingGroup needs to be created earlier. I now create and set the BindingGroup as the first thing in the View constructor. The binding in the XAML is no longer necessary. I'll post again with a corrected solution.