Esempio n. 1
0
    public void End( bool itemsSourceChanged, bool allowCancelingOfSelection, bool allowSynchronizeSelectionWithCurrent )
    {
      Debug.Assert( m_isActive );

      List<SelectionInfo> activatedSelectionDeltas = new List<SelectionInfo>();
      SelectionInfo selectionInfo;

      try
      {
        foreach( SelectionChanger selectionChanger in m_activatedSelectionChanger.Values )
        {
          selectionInfo = selectionChanger.GetSelectionInfo();

          if( !selectionInfo.IsEmpty )
          {
            activatedSelectionDeltas.Add( selectionInfo );
          }
        }

        if( activatedSelectionDeltas.Count > 0 )
        {
          DataGridSelectionChangingEventArgs eventArgs = new DataGridSelectionChangingEventArgs(
            new ReadOnlyCollection<SelectionInfo>( activatedSelectionDeltas ), allowCancelingOfSelection );

          m_owner.RaiseSelectionChanging( eventArgs );

          if( ( eventArgs.Cancel ) && ( allowCancelingOfSelection ) )
          {
            this.Cancel();
            throw new DataGridException( "Selection modification canceled." );
          }
        }

        foreach( SelectionChanger selectionChanger in m_activatedSelectionChanger.Values )
        {
          this.CommitSelectionChanger( selectionChanger, itemsSourceChanged );
        }

        if( ( allowSynchronizeSelectionWithCurrent ) && ( m_owner.SynchronizeSelectionWithCurrent ) )
        {
          this.UpdateCurrentToSelection();
        }
      }
      finally
      {
        m_isActive = false;
        m_activatedSelectionChanger.Clear();
      }

      // Notify that GlobalSelectedItems has changed if at least one selection has changed.
      if( activatedSelectionDeltas.Count > 0 )
      {
        for( int i = activatedSelectionDeltas.Count - 1; i >= 0; i-- )
        {
          selectionInfo = activatedSelectionDeltas[ i ];

          // Invoke the selection changed on the DataGridContext.
          selectionInfo.DataGridContext.InvokeSelectionChanged( selectionInfo );
        }

        m_owner.RaiseSelectionChanged(
          new DataGridSelectionChangedEventArgs(
            new ReadOnlyCollection<SelectionInfo>( activatedSelectionDeltas ) ) );

        m_owner.NotifyGlobalSelectedItemsChanged();
      }
    }
Esempio n. 2
0
 internal void RaiseSelectionChanging( DataGridSelectionChangingEventArgs e )
 {
   this.OnSelectionChanging( e );
 }
 internal void RaiseSelectionChanging( DataGridSelectionChangingEventArgs e )
 {
   using( m_inhibitPreviewGotKeyboardFocus.Set() )
   {
     this.OnSelectionChanging( e );
   }
 }
Esempio n. 4
0
 protected virtual void OnSelectionChanging( DataGridSelectionChangingEventArgs e )
 {
   this.RaiseEvent( e );
 }
        /// <summary>
        /// React on selection changing.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Selection changing event args.</param>
        private void _SelectionChanging(object sender, DataGridSelectionChangingEventArgs e)
        {
            NotifyCollectionChangedEventArgs args =
                CommonHelpers.GetSelectionChangedArgsFromGrid(e.SelectionInfos);

            _previousSelectedIndex = null;
            if (args.Action == NotifyCollectionChangedAction.Remove)
            {
                // Save preremoving selection.
                _previousSelectedIndex = SelectedIndex;
            }
        }