I don't know how clean this actually is in this case, but you could have the view model execute a "reverse command" that the view hooks (through a trigger or behavior) and does the stuff on the control. This concept is implemnted in the nRoute framework, so you can take a look at that for details.
Hope this helps ;) ________________________________________ From: [email protected] [[email protected]] On Behalf Of ross [[email protected]] Sent: Tuesday, July 27, 2010 6:15 AM To: ozWPF Subject: Re: MVVM Speaking of MVVM. Can anyone suggest a clean technique for the scenario where a 3rd party datagrid control needs to have a method called on it before saving the view model. I have a command on a save button that executes the save on the view model. All of the data is bound to the view model. However, to make it user friendly, the grid control needs to have the EndEdit() method called on it to resolve the binding in case the user is still editing a cell when they clicked save. The users can be trained to always click away from a cell, or hit <Enter> to end the edit, but of course I can't rely on that. It feels a bit annoying to use code behind, but what I have started doing is the following : View Model : private Action _saveCallBack; public void SetupFinaliseUICallback(Action saveCallBack) { _saveCallBack = saveCallBack; } private void Save() { if (_saveCallBack != null) _saveCallBack(); // final validation // persist the data } View code behind: void LoadingMainView_Loaded(object sender, RoutedEventArgs e) { ViewModel.SetupFinaliseUICallback(delegate() { loadingsGrid.EndEdit(); }); } _______________________________________________ ozwpf mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf _______________________________________________ ozwpf mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
