I have a DataGrid that their rows updated very quickly . every row has a right click event that if you click,this selected row should be added to another dataGrid. the problem is when user selected a row inorder to add to another list because of updating the selected row ,he couldnt add so user should be select the row again and again . my code is something like this
<DataGrid SelectionMode="Single" CanUserAddRows="False"CanUserDeleteRows="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="Data1" Binding="{Binding Path=Data1}"></DataGridTextColumn>
<DataGridTextColumn Header="Data2" Binding="{Binding Path=Data2}"></DataGridTextColumn>
<DataGridTextColumn Header="Data3" Binding="{Binding Path=Data3}"></DataGridTextColumn>
<DataGridTextColumn Header="Data4" Binding="{Binding Path=Data4}"></DataGridTextColumn>
<DataGridTextColumn Header="Data5" Binding="{Binding Path=Data5}"></DataGridTextColumn>
<DataGridTextColumn Header="Data6" Binding="{Binding Path=Data6}"></DataGridTextColumn>
</DataGrid.Columns>
<DataGrid.ContextMenu>
<ContextMenu HorizontalContentAlignment="Right" FlowDirection="RightToLeft">
<MenuItem Name="addToBlackListMnuBtn" Header="Add to Black List" Click="addToBlackListMnuBtn_Click" FontWeight="Black"/>
<MenuItem Name="addtoReportedListMnuBtn" Header="Add to Reported List" Click="addtoReportedListMnuBtn_Click" FontWeight="Black"/>
</ContextMenu>
</DataGrid.ContextMenu>
</DataGrid>
When I want to click "addtoReportedListMnuBtn" from contexMenu I should try several time for doing its event. usually show messageBox form the code below
private void addtoReportedListMnuBtn_Click(object sender, RoutedEventArgs e)//add to reported list
{
ObjClass en = (ObjClass)ActiveSignalDataGrid.SelectedItem;
if(en!=null)
{
ReportSignalsListQ.Data = en; // add to queue for adding
}else
{
MessageBox.Show("Please select again");
}
}
list because of updating the selected rowyou mean you are updating another datagrid selection ? - Anant Dabhi