Hey,
I have a Save button on a toolbar. My problem is that if I edit a cell and click the Save button on the toolbar without clicking off of the cell then the changes to the cell are not commited to the underlying object before my save logic occurs. If I use a regular button then everything is fine. I've had this problem before when binding to the XamTextEditor and it was related to the toolbar button not taking focus when it is clicked (when binding to the Value property of the text editor; binding the Text property works fine). Is there any way to force the changes to a cell to commit as they are made?
Also, is it possible to disable the image that indicates that a row is being edited or to have it turn off based on a property value? I have AllowEdit bound to a boolean on a view model and it would be nice to stop the image from being shown based on a binding.
Thanks
This is kind of a hack but it seems to be working:
{
}
//Move focus to the next element then move focus back to the originally focused
//element.
I'm not sure if there's a clean way to do that. There might be, but I don't know how. You could make a command that takes the datagrid out of edit mode, which would need to run this line of code:
this.xamDG.ExecuteCommand(DataPresenterCommands.EndEditModeAndAcceptChanges);
I tried using the approach in your article and for an ordinary grid cell, the Keyboard.FocusedElement happens to be a TextBox, but updating the source for the TextProperty binding doesn't seem to work. Does something complicated need to be done to flush a grid cell? Is it possible to set up the command to flush any control at all?
Ahh, composing commands like that is an awesome idea -- I wish I had seen that article a week ago when I was trying to figure this out for non-grid controls. Pure awesomeness, thanks!