silverlight crashes as datagrid in edit loses focus
so the goes something like this: I have two datagrids for editing data. One edits an array of strings, and the second edits an array of objects that contain multiple data fields (so, a matrix of some sort, essentially).
For some reason, when I click on the first datagrid (for array of strings) to edit a particular cell, if I click somewhere else outside the datagrid (say, a button outside) to exit edit, the interface hangs, and then Chrome (or IE) crashes. Even when I run the app in debug mode in VS, no errors were thrown.
Does anyone know how to hunt this bug down?
in MainPage.xaml:
<sdk:DataGrid AutoGenerateColumns="True" Canvas.Left="14" Canvas.Top="88" Height="165" Name="ObjectsGrid" Width="196" KeyDown="ObjectsGrid_KeyDown" CellEditEnding="ObjectsGrid_CellEditEnding">
in MainPage.xaml.cs:
private void ObjectsGrid_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Delete)
{
if (ObjectsGrid.SelectedItem != null)
{
ArrayOfString s = (ArrayOfString)ObjectsGrid.ItemsSource;
s.Remove((String)ObjectsGrid.SelectedItem);
ObjectsGrid.ItemsSource = n开发者_运维百科ull;
ObjectsGrid.ItemsSource = s;
}
}
}
private void ObjectsGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
DataGrid tGrid = (DataGrid)sender;
String c = ((TextBox)e.EditingElement).Text;
HashtableCollection[_currentCorrespondingItem].DataBoundObject[tGrid.SelectedIndex] = c;
}
and this is failing.
Does it get to the HitsGrid_CellEditending? If so, place a bracket at the { before "DataGrid tGrid" and keep pressing F11 untill you get to a error. If you get to any. If no error raises I can only assume the action you are performing in HintsGrid_CellEditEnding clears your datagrid or even application.
精彩评论