コード例 #1
0
 public RowValidationError(
   ValidationRule ruleInError,
   Row rowInError,
   object errorContent,
   Exception exception )
 {
   m_ruleInError = ruleInError;
   m_rowInError = rowInError;
   m_errorContent = errorContent;
   m_exception = exception;
 }
コード例 #2
0
ファイル: DataCell.cs プロジェクト: Torion/WpfExToolkit
    protected override void InitializeCore( DataGridContext dataGridContext, Row parentRow, ColumnBase parentColumn )
    {
      ColumnBase oldParentColumn = this.ParentColumn;

      base.InitializeCore( dataGridContext, parentRow, parentColumn );

      // This is a fix for Case 106982 (could not bind to XML datasources that contained namespaces).
      //
      // For an unknown reason, when a recycled DataCell was added back to the VisualTree (added
      // to the CellsHostPanel in its ParentRow), the binding would fail to update when the XPath
      // expression contained a namespace prefix, even if the XmlNamespaceManager property is inherited
      // and querying for the value of this property after adding the DataCell to the VTree would return
      // a valid, non-null XmlNamespaceManager.
      //
      // Forcing a local value for the XmlNamespaceManager property solves this problem, but it is
      // not the best thing to do as we are effectively bypassing the inheritance behavior for this
      // property...
      this.SetValue( Binding.XmlNamespaceManagerProperty, dataGridContext.DataGridControl.GetValue( Binding.XmlNamespaceManagerProperty ) );

      //prevent the setup of the display member binding more than once on the same column!
      if( ( !this.IsInternalyInitialized ) || ( oldParentColumn != parentColumn ) )
      {
        //call the helper function to setup the Cell's binding.
        this.SetupDisplayMemberBinding( dataGridContext );
      }
      else
      {

        BindingExpression binding = BindingOperations.GetBindingExpression( this, DataCell.ContentProperty );

        if( binding != null )
        {
          binding.UpdateTarget();
        }
      }
    }
コード例 #3
0
    private bool IsRowBeingEditedAndCurrentRowNotChanged( Row newRow, Row oldRow )
    {
      bool rowIsBeingEditedAndCurrentRowNotChanged = newRow.IsBeingEdited;

      if( rowIsBeingEditedAndCurrentRowNotChanged )
      {
        rowIsBeingEditedAndCurrentRowNotChanged &= ( newRow == oldRow );
      }

      return rowIsBeingEditedAndCurrentRowNotChanged;
    }
コード例 #4
0
    // Used to initialize/clear Column.CurrentRowInEditionCellState for each cell in the row passed as parameter
    internal void UpdateCurrentRowInEditionCellStates( Row newCurrentItemContainer, object newCurrentItemInEdition )
    {
      if( newCurrentItemInEdition != m_currentItemInEdition )
      {
        Row currentRowInEdition = null;

        if( m_currentItemInEdition != null )
        {
          // Get the container for m_currentItemInEdition
          currentRowInEdition = Row.FromContainer( this.CurrentContext.GetContainerFromItem( m_currentItemInEdition ) );

          if( newCurrentItemInEdition != null )
          {
            if( ( currentRowInEdition != null ) && ( currentRowInEdition.IsBeingEdited ) )
              throw new InvalidOperationException( "An attempt was made to place a row in edit mode while another row is being edited." );
          }
        }

        // The newCurrentItemContainer is null
        if( newCurrentItemContainer == null )
        {
          if( currentRowInEdition != null )
          {
            // We must clear the edition state of the old Row in edition
            foreach( Cell cell in currentRowInEdition.CreatedCells )
            {
              ColumnBase parentColumn = cell.ParentColumn;

              if( parentColumn == null )
                continue;

              parentColumn.CurrentRowInEditionCellState = null;
            }
          }
        }

        m_currentItemInEdition = newCurrentItemInEdition;
        m_currentRowInEditionState = new RowState();

        this.UpdateIsBeingEdited();
      }

      // It may occur that the newCurrentItemInEdition was set for a
      // Container that is currently out of view, so the newCurrentItemContainer
      // was null at this time. We must then ensure the CellStates are 
      // create for the newCurrentItemContainer when not null even if 
      // newCurrentItemInEdition == m_currentItemInEdition
      if( newCurrentItemContainer != null )
      {
        foreach( Cell cell in newCurrentItemContainer.CreatedCells )
        {
          ColumnBase parentColumn = cell.ParentColumn;

          if( parentColumn == null )
            continue;

          CellState cellState = new CellState();
          cellState.SetContentBeforeRowEdition( cell.Content );

          parentColumn.CurrentRowInEditionCellState = cellState;
        }
      }
    }
コード例 #5
0
    protected override void InitializeCore( DataGridContext dataGridContext, Row parentRow, ColumnBase parentColumn )
    {
      base.InitializeCore( dataGridContext, parentRow, parentColumn );

      this.SetColumnBinding( ColumnManagerCell.ContentProperty, parentColumn, ColumnBase.TitleProperty );
      this.SetColumnBinding( ColumnManagerCell.ContentTemplateProperty, parentColumn, ColumnBase.TitleTemplateProperty );
      this.SetColumnBinding( ColumnManagerCell.ContentTemplateSelectorProperty, parentColumn, ColumnBase.TitleTemplateSelectorProperty );
    }
コード例 #6
0
 /// <summary>
 /// Check that point is inside of the grid.
 /// </summary>
 /// <param name="row">Row with point.</param>
 /// <param name="point">Point to check.</param>
 /// <returns>'True' if point is inside visible part of the grid, 'false' otherwise.</returns>
 private bool _IsPointInsideGrid(Row row, Point point)
 {
     if (_dataGrid.InsertionRow == row && _dataGrid.IsBeingEdited)
         return _IsPointInsideGridOnVerticalHorizontalAxis(point, false);
     else
         return _IsPointInsideGridOnVerticalHorizontalAxis(point, true);
 }
コード例 #7
0
        /// <summary>
        /// Get visible part of the cell.
        /// </summary>
        /// <param name="cell">Cell with error.</param>
        /// <param name="row">Row with error.</param>
        /// <returns>Rect, representing visible part of the cell.</returns>
        private Rect _GetCellVisibleRectangle(Cell cell, Row row)
        {
            // Get top left and bottom right points of the cell.
            var topLeft = cell.PointToScreen(new Point(0, 0));
            var bottomRight = cell.PointToScreen(new Point(cell.ActualWidth, cell.ActualHeight));

            // If both points isnt inside of the grid, thath mean that cell isnt visible.
            if (!_IsPointInsideGrid(row, topLeft) && !_IsPointInsideGrid(row, bottomRight))
                return Rect.Empty;

            // Calculate vertical offset.
            double verticalOffset;
            // If cell is in insertion row or if grid have no insertion row -
            // offset is equal to the height of the grid heading row.
            if (row == _dataGrid.InsertionRow || _dataGrid.InsertionRow == null)
                verticalOffset = HEADING_ROW_HEIGHT;
            else
                verticalOffset = _gridHeadingRowAndInsertionRowHeight;

            // Detect grid first row top left point.
            var gridTopLeftPoint = _dataGrid.PointToScreen(new Point(0, verticalOffset));
            // Translate this point to cell coordinate.
            var cellGridTopLeftPoint = cell.PointFromScreen(gridTopLeftPoint);
            // Correct cell visible rectangle if necessary.
            if (cellGridTopLeftPoint.X > 0)
                topLeft.X = gridTopLeftPoint.X;
            if (cellGridTopLeftPoint.Y > 0)
                topLeft.Y = gridTopLeftPoint.Y;

            // Detect grid bottom right point.
            var gridRightEdge = _dataGrid.PointToScreen(
                new Point(_dataGrid.ActualWidth, _dataGrid.ActualHeight));
            // Translate this point to cell coordinate.
            var cellGridRightEdge = cell.PointFromScreen(gridRightEdge);
            // Correct cell visible rectangle if necessary.
            if (cellGridRightEdge.X < cell.ActualWidth)
                bottomRight.X = gridRightEdge.X;
            if (cellGridRightEdge.Y < cell.ActualHeight)
                bottomRight.Y = gridRightEdge.Y;

            return new Rect(topLeft, bottomRight);
        }
コード例 #8
0
        /// <summary>
        /// Get cell with error.
        /// </summary>
        /// <returns><c>Xceed.Wpf.DataGrid.Cell</c>.</returns>
        private Cell _FindCellWithError(Row row)
        {
            // If row is null - return null.
            if (row != null)
            {
                // Get cell with invalid property.
                var cell = (row as Row).Cells[_column];

                // If we havent found scroll viever - do find it.
                if (_scrollViewer == null)
                    _SubscribeOnScroller(cell);

                // If this cell is visible - return it.
                if (cell != null && cell.IsVisible)
                    return cell;
            }

            // If we come here - cell couldnt be found.
            return null;
        }
コード例 #9
0
 protected internal virtual void AddContentBinding( DataGridContext dataGridContext, Row parentRow, ColumnBase parentColumn )
 {
 }
コード例 #10
0
ファイル: Row.cs プロジェクト: Torion/WpfExToolkit
 internal static bool IsCellEditorDisplayConditionsSet( Row row, CellEditorDisplayConditions condition )
 {
   return ( ( row.CellEditorDisplayConditions & condition ) == condition );
 }
コード例 #11
0
ファイル: Row.cs プロジェクト: Torion/WpfExToolkit
    internal static void SetRowValidationErrorOnException( Row row, Exception exception )
    {
      System.Diagnostics.Debug.Assert( ( row != null ) && ( exception != null ) );

      // This method will set a validation error on the row and throw back a DataGridValidationException so that 
      // the row stays in edition.

      if( exception is TargetInvocationException )
        exception = exception.InnerException;

      row.SetValidationError( new RowValidationError(
      Row.CustomRowValidationExceptionValidationRule,
      row,
      exception.Message,
      exception ) );

      // Throwing a DataGridValidationException will be caught by the grid and will make the cell stay in edition.
      throw new DataGridValidationException( "An error occurred while attempting to end the edit process.", exception );
    }
コード例 #12
0
        /// <summary>
        /// Mouse move handler.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _MouseMove(object sender, MouseEventArgs e)
        {
            // Check if some row is hovered.
            Row currentRow = XceedVisualTreeHelper.GetRowByEventArgs(e);

            if (currentRow != null)
            {
                // Check is hovered row are different from last hovered.
                if (!currentRow.Equals(_currentRow))
                {
                    // Start OR re-start timer since user hovered to some another row.
                    _currentRow = currentRow;
                    _bringItemIntoViewTimer.IsEnabled = true;
                    _bringItemIntoViewTimer.Start();
                }
            }
            else
            {
                // Disable timer since user leaved last row.
                _bringItemIntoViewTimer.Stop();
                _bringItemIntoViewTimer.IsEnabled = false;
            }

            // if property sets to false - return
            if (!_multipleItemsDragSupport)
                return;

            _ResetSelectionFields();
        }
コード例 #13
0
ファイル: Cell.cs プロジェクト: Torion/WpfExToolkit
    protected internal void Initialize( DataGridContext dataGridContext, Row parentRow, ColumnBase parentColumn )
    {
      //Check that both parameters are valid.
      if( parentRow == null )
        throw new ArgumentNullException( "parentRow" );

      if( parentColumn == null )
        throw new ArgumentNullException( "parentColumn" );

      //There is nothing to be done if the cell is being reinitialized with
      //the same parent row and the same parent column.
      if( ( this.IsInternalyInitialized )
        && ( parentColumn == this.ParentColumn )
        && ( parentRow == this.ParentRow ) )
        return;

      //Mark the cell has being recycled to prevent some check to occur.
      this.IsContainerRecycled = this.IsInternalyInitialized;

      //A cell that hasn't been prepare once or that has a new parent column
      //due to recycling needs to be prepared again.
      this.IsContainerPrepared = false;

      this.InitializeCore( dataGridContext, parentRow, parentColumn );

      //Set the Initialized flag to True for the Cell instance.
      this.IsInternalyInitialized = true;

      this.PostInitialize();

      //From here, there is no difference between a fresh new cell and
      //a recycled cell.
      this.IsContainerRecycled = false;
    }
コード例 #14
0
ファイル: Cell.cs プロジェクト: Torion/WpfExToolkit
    protected virtual void InitializeCore( DataGridContext dataGridContext, Row parentRow, ColumnBase parentColumn )
    {
      //Initialize the Cell's Properties.
      this.SetParentRow( parentRow );
      this.SetParentColumn( parentColumn );

      if( !this.IsInternalyInitialized )
      {
        Binding rowMatchingConditionsBinding = new Binding();
        rowMatchingConditionsBinding.Path = new PropertyPath( "(0).(1)",
          Cell.ParentRowProperty,
          Row.RowDisplayEditorMatchingConditionsProperty );
        rowMatchingConditionsBinding.Source = this;
        rowMatchingConditionsBinding.Mode = BindingMode.OneWay;

        //Initialize the RowDisplayEditorMatchingConditions binding to the ParentRow
        BindingOperations.SetBinding(
          this, Cell.RowDisplayEditorMatchingConditionsProperty,
          rowMatchingConditionsBinding );

        // Clear the FieldName since it will be taken from the column instead of directly from the Cell.
        this.SetFieldName( string.Empty );
      }
    }
コード例 #15
0
ファイル: Cell.cs プロジェクト: Torion/WpfExToolkit
    private void SetParentRow( Row value )
    {
      if( value == null )
        throw new ArgumentNullException( "value" );

      // There is nothing to do if the parent row is the same.
      if( value == m_parentRow )
        return;

      m_parentRow = value;
      this.SetValue( Cell.ParentRowPropertyKey, value );
    }
コード例 #16
0
    private bool TryGetCellFittedWidth( Row row, out double fittedWidth )
    {
      fittedWidth = -1;

      if( row == null )
        return false;

      Cell cell;
      CellCollection cells = row.Cells;
      VirtualizingCellCollection virtualCells = cells as VirtualizingCellCollection;
      bool releaseCell = false;

      if( virtualCells != null )
      {
        if( !virtualCells.TryGetCell( this, out cell ) )
        {
          releaseCell = true;
          cell = virtualCells[ this ];

          Debug.Assert( cell != null );

          if( !cell.IsMeasureValid )
          {
            cell.Measure( Size.Empty );
          }
        }
      }
      else
      {
        cell = cells[ this ];
      }

      Debug.Assert( cell != null );
      fittedWidth = cell.GetFittedWidth();

      // A cell that was created or recycled to calculate the fitted width must be released
      // in order to minimize the number of cells created overall.
      if( releaseCell )
      {
        Debug.Assert( virtualCells != null );
        virtualCells.Release( cell );
      }

      return true;
    }
コード例 #17
0
    protected override void InitializeCore( DataGridContext dataGridContext, Row parentRow, ColumnBase parentColumn )
    {
      base.InitializeCore( dataGridContext, parentRow, parentColumn );

      this.SetContent( parentColumn );
      this.SetContentTemplate( parentColumn );
      this.SetContentTemplateSelector( parentColumn );
    }
コード例 #18
0
    private void SetParentRow( Row value )
    {
      if( value == null )
        throw new ArgumentNullException( "value" );

      this.SetValue( Cell.ParentRowPropertyKey, value );
    }