示例#1
0
 protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
 {
     base.OnPropertyChanged(e);
     if (e.Property == HeaderHeightProperty)
     {
         PositionHeaderCells(ActualWidth);
     }
     if (e.Property == RowHeightProperty)
     {
         PositionRows(ActualWidth);
     }
     if (e.Property == ItemsProperty)
     {
         InvalidateRows();
         PositionRows(ActualWidth);
     }
     if (e.Property == ActualWidthProperty || e.Property == ActualHeightProperty)
     {
         PositionRows(ActualWidth);
         PositionHeaderCells(ActualWidth);
         PositionScroll(ActualWidth);
     }
     if (e.Property == SelectedItemProperty)
     {
         SetSelection(new[] { SelectedItem }, null, null, null);
     }
     if (e.Property == SelectedItemsProperty)
     {
         SetSelection(SelectedItems.ToArray(), null, null, null);
     }
     if (e.Property == SelectedRowsProperty)
     {
         SetSelection(null, SelectedRows.ToArray(), null, null);
     }
     if (e.Property == SelectedColumnsProperty)
     {
         SetSelection(null, null, SelectedColumns.ToArray(), null);
     }
     if (e.Property == SelectedCellsProperty)
     {
         SetSelection(null, null, null, SelectedCells.ToArray());
     }
 }