views:

240

answers:

0

I use the MVVM pattern and I have the following code:

<DataTemplate x:Key="ActivityEditTemplate">
        <ItemsControl ItemsSource="{Binding Path=ActivityList}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>                       
                    <CheckBox Margin="2,0,2,0" Content="{Binding ActivityDescription}" IsChecked="{Binding IsSelected}" Command="vm:PatternViewModel.ActivityCommand" CommandParameter="{Binding ActivityTitle}">
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </DataTemplate>

The check box within the ItemsControl needs to allow for a multiselect. I have a routed command and can easily implement it on the checkbox, however I only want the command to execute when the items control is collapsed. The datatemplate is a static resource of an CellEditingTemplate in a WPF datagrid. I would like the code to still adopt the MVVM pattern. I considered the mouse leave event calling the command with no luck. Thanks in advance.