/// <summary>
 ///     Instantiates a new instance of this class.
 /// </summary>
 /// <param name="column">The column of the cell that is about to exit edit mode.</param>
 /// <param name="row">The row container of the cell container that is about to exit edit mode.</param>
 /// <param name="editingElement">The editing element within the cell.</param>
 /// <param name="editingUnit">The editing unit that is about to leave edit mode.</param>
 public DataGridCellEditEndingEventArgs(DataGridColumn column, DataGridRow row, FrameworkElement editingElement, DataGridEditAction editAction)
 {
     _dataGridColumn = column;
     _dataGridRow = row;
     _editingElement = editingElement;
     _editAction = editAction;
 }
Beispiel #2
0
        public static string GetSortMemberPath(DataGridColumn column)
        {
            // find the sortmemberpath
            string sortPropertyName = column.SortMemberPath;
            if (string.IsNullOrEmpty(sortPropertyName))
            {
                var boundColumn = column as DataGridBoundColumn;
                if (boundColumn != null)
                {
                    var binding = boundColumn.Binding as Binding;
                    if (binding != null)
                    {
                        if (!string.IsNullOrEmpty(binding.XPath))
                        {
                            sortPropertyName = binding.XPath;
                        }
                        else if (binding.Path != null)
                        {
                            sortPropertyName = binding.Path.Path;
                        }
                    }
                }
            }

            return sortPropertyName;
        }
 /// <summary>
 ///     Constructs a new instance of these event arguments.
 /// </summary>
 /// <param name="column">The column of the cell that just entered edit mode.</param>
 /// <param name="row">The row container that contains the cell container that just entered edit mode.</param>
 /// <param name="editingEventArgs">The event arguments, if any, that led to the cell being placed in edit mode.</param>
 /// <param name="cell">The cell container that just entered edit mode.</param>
 /// <param name="editingElement">The editing element within the cell container.</param>
 public DataGridPreparingCellForEditEventArgs(DataGridColumn column, DataGridRow row, RoutedEventArgs editingEventArgs, FrameworkElement editingElement)
 {
     _dataGridColumn = column;
     _dataGridRow = row;
     _editingEventArgs = editingEventArgs;
     _editingElement = editingElement;
 }
 public ColumnInformation(DataGridColumn column)
 {
     Header = column.Header;
     if (!(column is DataGridTemplateColumn))
     {
         if (column is DataGridComboBoxColumn)
         {
             PropertyPath = column.SortMemberPath;
         }
         else
         {
             PropertyPath = ((Binding)((DataGridBoundColumn)column).Binding).Path.Path;
         }
     }
     else
     {
         PropertyPath = column.SortMemberPath;
     }
     WidthValue = column.Width.DisplayValue;
     WidthType = column.Width.UnitType;
     SortDirection = column.SortDirection;
     DisplayIndex = column.DisplayIndex;
     SortMemberPath = column.SortMemberPath;
     IsVisible = column.IsVisible;
 }
        internal DataGridCellInfo(object item, DataGridColumn column, DataGrid owner)
        {
            Debug.Assert(item != null, "item should not be null.");
            Debug.Assert(column != null, "column should not be null.");
            Debug.Assert(owner != null, "owner should not be null.");

            _item = item;
            _column = column;
            _owner = new WeakReference(owner);
        }
 internal DataGridAutoGeneratingColumnEventArgs(
     DataGridColumn column,
     string propertyName,
     Type propertyType,
     object propertyDescriptor)
 {
     _column = column;
     _propertyName = propertyName;
     _propertyType = propertyType;
     PropertyDescriptor = propertyDescriptor;
 }
        /// <summary>
        ///     Identifies a cell at the column within the row for the specified item.
        /// </summary>
        /// <param name="item">The item who's row contains the cell.</param>
        /// <param name="column">The column of the cell within the row.</param>
        /// <remarks>
        ///     This constructor will not tie the DataGridCellInfo to any particular
        ///     DataGrid.
        /// </remarks>
        public DataGridCellInfo(object item, DataGridColumn column)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            _item = item;
            _column = column;
            _owner = null;
        }
        /// <summary>
        /// Called when the Header property on a Column changes.  Causes us to fire a CollectionChanged event to specify that an item has been replaced.
        /// </summary>
        /// <param name="column"></param>
        internal void NotifyHeaderPropertyChanged(DataGridColumn column, DependencyPropertyChangedEventArgs e)
        {
            Debug.Assert(e.Property == DataGridColumn.HeaderProperty, "We only want to know about the header property changing");
            Debug.Assert(_columns.Contains(column));

            NotifyCollectionChangedEventArgs args = new NotifyCollectionChangedEventArgs(
                NotifyCollectionChangedAction.Replace,
                e.NewValue,
                e.OldValue,
                _columns.IndexOf(column));

            FireCollectionChanged(args);
        }
 public void Apply(DataGridColumn column, int gridColumnCount, SortDescriptionCollection sortDescriptions)
 {
     column.Width = new DataGridLength(WidthValue, WidthType);
     column.SortDirection = SortDirection;
     if (SortDirection != null)
     {
         sortDescriptions.Add(new SortDescription(PropertyPath, SortDirection.Value));
     }
     if (column.DisplayIndex != DisplayIndex)
     {
         var maxIndex = (gridColumnCount == 0) ? 0 : gridColumnCount - 1;
         column.DisplayIndex = (DisplayIndex <= maxIndex) ? DisplayIndex : maxIndex;
     }
     column.Visibility = IsVisible ? Visibility.Visible : Visibility.Collapsed;
     column.SortMemberPath = SortMemberPath;
 }
 public DataGridSortingEventArgs(DataGridColumn column)
     : base(column)
 {
 }
 /// <summary>
 /// Construct DataGridCellClipboardEventArgs object
 /// </summary>
 /// <param name="item"></param>
 /// <param name="column"></param>
 /// <param name="content"></param>
 public DataGridCellClipboardEventArgs(object item, DataGridColumn column, object content)
 {
     _item = item;
     _column = column;
     _content = content;
 }
 internal DataGridAutoGeneratingColumnEventArgs(DataGridColumn column, ItemPropertyInfo itemPropertyInfo) : 
     this(column, itemPropertyInfo.Name, itemPropertyInfo.PropertyType, itemPropertyInfo.Descriptor)
 {
 }
 /// <summary>
 /// Public constructor
 /// </summary>
 /// <param name="propertyName"></param>
 /// <param name="propertyType"></param>
 /// <param name="column"></param>
 public DataGridAutoGeneratingColumnEventArgs(string propertyName, Type propertyType, DataGridColumn column) :
     this(column, propertyName, propertyType, null)
 {
 }
 /// <summary>
 ///     Instantiates a new instance of this class.
 /// </summary>
 public DataGridColumnEventArgs(DataGridColumn column)
 {
     _column = column;
 }
        /// <summary>
        ///     This is used strictly to create the partial CellInfos.
        /// </summary>
        /// <remarks>
        ///     This is being kept private so that it is explicit that the
        ///     caller expects invalid data.
        /// </remarks>
        private DataGridCellInfo(DataGrid owner, DataGridColumn column, object item)
        {
            Debug.Assert(owner != null, "owner should not be null.");

            _item = item;
            _column = column;
            _owner = new WeakReference(owner);
        }
        /// <summary>
        ///     This is used by CurrentCell if there isn't a valid CurrentItem or CurrentColumn.
        /// </summary>
        internal static DataGridCellInfo CreatePossiblyPartialCellInfo(object item, DataGridColumn column, DataGrid owner)
        {
            Debug.Assert(owner != null, "owner should not be null.");

            if ((item == null) && (column == null))
            {
                return Unset;
            }
            else
            {
                return new DataGridCellInfo(owner, column, (item == null) ? DependencyProperty.UnsetValue : item);
            }
        }