/// <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 static int CompareColumnPosition(Microsoft.Windows.Controls.DataGridColumn x, Microsoft.Windows.Controls.DataGridColumn y)
        {
            if (x == y)
            {
                return(0);
            }
            if (x == null)
            {
                if (y == null)
                {
                    // If x is null and y is null, they're
                    // equal.
                    return(0);
                }
                // If x is null and y is not null, y
                // is greater.
                return(-1);
            }
            // If x is not null...
            //
            if (y == null)
            // ...and y is null, x is greater.
            {
                return(1);
            }
            // ...and y is not null, compare the
            // lengths of the two strings.
            //
            int retval = x.DisplayIndex.CompareTo(y.DisplayIndex);

            return(retval != 0 ? retval : 9);
        }
 /// <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;
 }
        public static void Save(int index, DataGridColumn column, Stream stream)
        {
            if (stream == null) throw new ArgumentNullException("stream");
            DataGridColumnSettings settings = new DataGridColumnSettings();
            settings.AssignFrom(column, index);

            XmlSerializer serializer = new XmlSerializer(typeof (DataGridColumnSettings));
            serializer.Serialize(stream, settings);
        }
        private void AssignFrom(DataGridColumn column, int index)
        {
            Visible = (column.Width.Value > 0);

            DisplayIndex = column.DisplayIndex == -1 ? index : column.DisplayIndex;
            Width = column.Width.Value;
            MinWidth = column.MinWidth;
            LengthUnitType = column.Width.UnitType;
        }
Пример #6
0
        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);
        }
        public static void Restore(DataGridColumn column, Stream stream)
        {
            if (stream == null) throw new ArgumentNullException("stream");
            if (column == null) throw new ArgumentNullException("column");

            XmlSerializer serializer = new XmlSerializer(typeof (DataGridColumnSettings));
            DataGridColumnSettings settings = (DataGridColumnSettings) serializer.Deserialize(stream);
            if (settings != null)
                settings.AssignTo(column);
        }
Пример #8
0
        /// <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;
        }
 internal DataGridAutoGeneratingColumnEventArgs(
     DataGridColumn column,
     string propertyName,
     Type propertyType,
     object propertyDescriptor)
 {
     _column = column;
     _propertyName = propertyName;
     _propertyType = propertyType;
     PropertyDescriptor = propertyDescriptor;
 }
Пример #10
0
 private void AssignTo(DataGridColumn column)
 {
     if (Visible)
     {
         column.Width = new DataGridLength(Width,LengthUnitType);
         column.MinWidth = MinWidth;
     }
     else
     {
         UnvisibleColumn(column);
     }
     column.DisplayIndex = DisplayIndex;
 }
Пример #11
0
        /// <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);
        }
Пример #12
0
        public static string GetPath(DataGridColumn column)
        {
            DataGridBoundColumn gridBoundColumn = column as DataGridBoundColumn;

            string path = null;
            if(gridBoundColumn!=null)
            {
                Binding binding = (Binding)gridBoundColumn.Binding;
                path = binding.Path.Path;
            }
            else
            {
                IBindableDataGridColumn dbObjectColumn = (IBindableDataGridColumn)column;
                path = dbObjectColumn.BindingPath;
            }
            return path;
        }
Пример #13
0
        public static object GetFieldByColumn(DataGridColumn column, object value)
        {
            string path = GetPath(column);

            return GetValueByPath(path, value);
        }
 /// <summary>
 /// Creates a new DataGridClipboardCellValue structure containing information about DataGrid cell
 /// </summary>
 /// <param name="row">DataGrid row item containing the cell</param>
 /// <param name="column">DataGridColumn containing the cell</param>
 /// <param name="value">DataGrid cell value</param>
 public DataGridClipboardCellContent(object item, DataGridColumn column, object content)
 {
     _item = item;
     _column = column;
     _content = content;
 }
 /// <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)
 {
 }
Пример #16
0
 public static void UnvisibleColumn(DataGridColumn column)
 {
     column.Width = new DataGridLength(0);
     column.MinWidth = 0;
 }
 internal DataGridAutoGeneratingColumnEventArgs(DataGridColumn column, ItemPropertyInfo itemPropertyInfo) : 
     this(column, itemPropertyInfo.Name, itemPropertyInfo.PropertyType, itemPropertyInfo.Descriptor)
 {
 }
 /// <summary>
 ///     Instantiates a new instance of this class.
 /// </summary>
 public DataGridColumnEventArgs(DataGridColumn column)
 {
     _column = column;
 }
Пример #19
0
        /// <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);
        }
Пример #20
0
        /// <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);
            }
        }
 public DataGridSortingEventArgs(DataGridColumn column)
     : base(column)
 {
 }