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
Hi,
Regarding the focus not being lost in the grid cell upon clicking a button in a toolbar, that is a common WPF gotcha, not related to Infragistics controls. I wrote an article that shows how to deal with that when working with commands, perhaps it will shed some light on the issue for you.
http://www.codeproject.com/KB/WPF/commandgroup.aspx
Regarding the edit icon in the record selector, I am not aware of a way to turn that off via data binding. I think you will have to make a custom control template for the record selectors and bind the Visibility of your edit visuals to whatever property you have on the viewmodel. If this feature is important to you, perhaps you might log a feature request for it.
Thanks,
Josh
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!
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?
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);
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.