/************************************************************************/ #region Constructor /// <summary> /// Initializes a new instance of the <see cref="DataGridColumnSortSpec"/> class. /// </summary> /// <param name="column1"> /// The name of the column to use as the primary sort, or null to allow the column in the process of sorting to be the primary. /// </param> /// <param name="column2">The name of the column to use as the secondary sort.</param> /// <param name="behavior">The column's behavior</param> public DataGridColumnSortSpec(string column1, string column2, DataGridColumnSortBehavior behavior) { if (string.IsNullOrEmpty(column2)) { throw new ArgumentNullException(nameof(column2)); } Column1 = column1; Column2 = column2; Behavior = behavior; }
/// <summary> /// Adds a custom sort specification (alias of <see cref="AddSort(DataGridColumn, string, string, DataGridColumnSortBehavior)"/> /// </summary> /// <param name="col">The column</param> /// <param name="column1">The name of the column to act as primary sort, or null to use the <paramref name="col"/></param> /// <param name="column2">The name of the column to act as a secondary sort.</param> /// <param name="behavior">The behavior of the secondary column when sorting.</param> /// <returns>The column</returns> public static DataGridColumn AddCustomSort(this DataGridColumn col, string column1, string column2, DataGridColumnSortBehavior behavior) { return(col.AddSort(column1, column2, behavior)); }
/// <summary> /// Adds a sort specification to the column /// </summary> /// <param name="col">The column</param> /// <param name="column1">The name of the column to act as primary sort, or null to use the <paramref name="col"/></param> /// <param name="column2">The name of the column to act as a secondary sort.</param> /// <param name="behavior">The behavior of the secondary column when sorting.</param> /// <returns>The column</returns> /// <remarks> /// This extension adds a <see cref="DataGridColumnSortSpec"/> property to the column, creating /// a secondary sort on this column. /// </remarks> public static DataGridColumn AddSort(this DataGridColumn col, string column1, string column2, DataGridColumnSortBehavior behavior) { col.SetValue(DataGrid.CustomSortProperty, new DataGridColumnSortSpec(column1, column2, behavior)); return(col); }