Esempio n. 1
0
 internal static void SetColumnReorderingDragSourceManager( DependencyObject obj, ColumnReorderingDragSourceManager value )
 {
   obj.SetValue( TableflowView.ColumnReorderingDragSourceManagerProperty, value );
 }
    private void SetupDragManager()
    {
      var dataGridContext = this.DataGridContext;
      // Can be null in design-time (edition of a style TargetType ColumnManagerCell).
      if( dataGridContext == null )
        return;

      // We do not support DragDrop when there are no AdornerLayer because there wouldn't be any visual feedback for the operation.
      AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer( this );
      if( adornerLayer == null )
      {
        // When virtualizing, the Cell is not yet in the VisualTree because it is the ParentRow's CellsHost which
        // is reponsible of putting them in the VisualTree. We try to get the adorner from the ParentRow instead
        if( this.ParentRow != null )
        {
          adornerLayer = AdornerLayer.GetAdornerLayer( this.ParentRow );
        }

        if( adornerLayer == null )
          return;
      }

      var dataGridControl = dataGridContext.DataGridControl;
      if( dataGridControl == null )
        return;

      if( m_dragSourceManager != null )
      {
        m_dragSourceManager.PropertyChanged -= this.DragSourceManager_PropertyChanged;
      }

      // The DataGridControl's AdornerDecoratorForDragAndDrop must be used for dragging in order to include the RenderTransform
      // the DataGridControl may performs. This AdornerDecorator is defined in the ControlTemplate as PART_DragDropAdornerDecorator
      if( ( dataGridControl.DragDropAdornerDecorator != null ) && ( dataGridControl.DragDropAdornerDecorator.AdornerLayer != null ) )
      {
        m_dragSourceManager = new ColumnReorderingDragSourceManager( this, dataGridControl.DragDropAdornerDecorator.AdornerLayer, dataGridControl, this.ParentRow.LevelCache );
      }
      else
      {
        m_dragSourceManager = new ColumnReorderingDragSourceManager( this, null, dataGridControl, this.ParentRow.LevelCache );
      }

      m_dragSourceManager.PropertyChanged += this.DragSourceManager_PropertyChanged;

      // Create bindings to ViewProperties for AutoScroll Properties
      Binding binding = new Binding();
      binding.Path = new PropertyPath( "(0).(1)", DataGridControl.DataGridContextProperty, TableView.AutoScrollIntervalProperty );
      binding.Mode = BindingMode.OneWay;
      binding.Source = this;
      BindingOperations.SetBinding( m_dragSourceManager, DragSourceManager.AutoScrollIntervalProperty, binding );

      binding = new Binding();
      binding.Path = new PropertyPath( "(0).(1)", DataGridControl.DataGridContextProperty, TableView.AutoScrollTresholdProperty );
      binding.Mode = BindingMode.OneWay;
      binding.Source = this;
      BindingOperations.SetBinding( m_dragSourceManager, DragSourceManager.AutoScrollTresholdProperty, binding );
    }
    private void RemoveDraggedColumnGhost( ColumnReorderingDragSourceManager manager )
    {
      if( !manager.ContainsDraggedColumnGhost( this ) )
        return;

      manager.RemoveDraggedColumnGhost( this );

      this.ClearValue( Cell.OpacityProperty );
    }
 internal virtual void SetColumnReorderingDragSourceManager( ColumnReorderingDragSourceManager value )
 {
   TableflowView.SetColumnReorderingDragSourceManager( this, value );
 }
    private void AddDraggedColumnGhost( ColumnReorderingDragSourceManager manager, bool isBeingDraggedAnimated )
    {
      if( !isBeingDraggedAnimated || !this.IsContainerPrepared || manager.ContainsDraggedColumnGhost( this ) )
        return;

      this.ClearValue( Cell.OpacityProperty );

      manager.AddDraggedColumnGhost( this );
    }