<ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="Remove Member" Command="{Binding RemoveMemberCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ContextMenu}}, Path=PlacementTarget}"/>
</ContextMenu>
</ListView.ContextMenu>
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource gridViewHeaderStyle2}"
ColumnHeaderTemplate="{StaticResource HeaderTemplateTransparent}">
<deskTopViewMgt:SortableGridViewColumn Header="Member Id" SortPropertyName="MemberId" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding MemberId}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</deskTopViewMgt:SortableGridViewColumn>
</GridView>
</ListView.View>
</deskTopViewMgt:SortableListView>
public ICommand RemoveMemberCommand { get { if (_removeMemberCommand == null) {
_removeMemberCommand = new SNADelegateCommand(deleteMembersList);
}
return _removeMemberCommand;
}
}
void deleteMembersList(object selectedItemsList) { ListView lst = (ListView)selectedItemsList;
//--
// Cast the SelectedItemCollection
//--
IList selectedList = (IList)lst.SelectedItems;
IList<INetworkMemberXref> removeItems = selectedList.Cast<INetworkMemberXref>()
.ToList<INetworkMemberXref>();
foreach (INetworkMemberXref lineItem in removeItems)
{
INetworkMemberXref removedmember = _remoteDomain.Domain.GetNetworkMemberXref();
_associatedMembers.Remove(lineItem);
removedmember = lineItem;
if (!this.membersRemoved.Contains(removedmember))
{
this.membersRemoved.Add(removedmember);
}
}
lst.SelectedItems.Clear();
}
The grid menu item might have some kind of property because when ever i select the grid Items with the control keys and unselect one of the item the grid thinks that the items are not unselected. i don't know why it's happening the grid should know which items are selected and unselected but grid thinks that even the unselected items are still selected.
Please help me on this.