Hi,
I am using MVVM model for my application. I have 2 Views that contains a GridView each. Both of them are binding to the same command in the ViewModel for GridView's selection changed.
<GridControl Grid.Row="0" Grid.Column="1" x:Name="TaskItemsGridView" SelectionChangedCommand=" {Binding ShowSelectedTaskCommand}" ItemsSource="{Binding ActiveTaskList, Mode=TwoWay}" SelectedItem="{Binding ActiveTask, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
ShowSelectedTaskCommand is invoking a function that performs some functions and updates ActiveTask.
I am facing two issues here.
a) I need to do an additional db save after which the ActiveTask will be set , when selection changed command is invoked from View1. My issue is even if I make the commands separate to handle this situation, both the commands are executed as I need to update ActiveTask in between. So if one command updates ActiveTask, it will fire SelectionChanged for other command. How can i tackle this situation. b) Since both functions are called in both cases, how can I add some condition to perform db save.
Below is my func for reference
private void ShowSelectedTask()
{
if (ActiveTask.EventId != TaskId && !string.IsNullOrEmpty(ActiveTaskName))
UpdateTaskInformation(TaskId);
if (ActiveTask != null)
{
TaskId = ActiveTask.EventId;
....
}
}
Note: The only difference in the functionalities from both the view is the additional db save. Rest of the code are common for both. Please help.
Thanks