2011-01-17 2 views
6

WPF 툴킷 DataGrid를 사용하고 있습니다. SelectionUnit = "Cell"SelectionMode = "Extended"으로 설정했습니다.WPF Datagrid : SelectionUnit = "Cell"일 때 SelectionChanged 이벤트가 발생하지 않습니다.

SelectionChanged 이벤트가 발생하지 않습니다!

SelectionUnit이 FullRow로 설정된 경우 제대로 작동합니다.

내가 누락 된 항목이 있습니까?

지금 내가 SelectedCell을 내 ViewModel에 바인딩하는 데 도움이되는 부속 속성을 만들려고하고 있기 때문에 필요한 이유가 있습니다.

답변

7

DataGrid.SelectedCellsChanged을 사용 하시려면 provide you으로 해주십시오.

private void DG1_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) 
{ 
    //Get the newly selected cells 
    IList<DataGridCellInfo> selectedcells = e.AddedCells; 

    //Get the value of each newly selected cell 
    foreach (DataGridCellInfo di in selectedcells) 
    { 
     //Cast the DataGridCellInfo.Item to the source object type 
     //In this case the ItemsSource is a DataTable and individual items are DataRows 
     DataRowView dvr = (DataRowView)di.Item; 

     //Clear values for all newly selected cells 
     AdventureWorksLT2008DataSet.CustomerRow cr = (AdventureWorksLT2008DataSet.CustomerRow)dvr.Row; 
     cr.BeginEdit(); 
     cr.SetField(di.Column.DisplayIndex, ""); 
     cr.EndEdit(); 

    } 
} 
+0

아론의 권리. SelectionChanged는 실제로 작동하고 필요한 정보를 제공합니다. – GuYsH

관련 문제