private static object GetCellItem(this DataGridColumn column, object item) { if (column == null || item == null) { return(null); } var descriptor = (PropertyDescriptor)column.GetValue(PropertyDescriptorProperty); if (descriptor != null) { return(descriptor.GetValue(item)); } var binding = (column as DataGridBoundColumn)?.Binding as Binding; if (binding == null) { return(null); } descriptor = TypeDescriptor.GetProperties(item) .OfType <PropertyDescriptor>() .SingleOrDefault(x => x.Name == binding.Path.Path); column.SetValue(PropertyDescriptorProperty, descriptor); return(descriptor?.GetValue(item)); }
public void ConfigureFilter(DataGridColumn column, bool canUserSelectDistinct, bool canUserGroup, bool canUserFreeze, bool canUserFilter) { column.SetValue(ColumnConfiguration.CanUserFilterProperty, canUserFilter); column.SetValue(ColumnConfiguration.CanUserFreezeProperty, canUserFreeze); column.SetValue(ColumnConfiguration.CanUserGroupProperty, canUserGroup); column.SetValue(ColumnConfiguration.CanUserSelectDistinctProperty, canUserSelectDistinct); var ctrl = Filters.Where(i => i.FilterColumnInfo.Column == column).FirstOrDefault(); if (ctrl != null) { ctrl.CanUserSelectDistinct = canUserSelectDistinct; ctrl.CanUserGroup = canUserGroup; ctrl.CanUserFreeze = canUserFreeze; ctrl.CanUserFilter = canUserFilter; } }
/// <summary>Control the visibility of the filter for this column.</summary> public static void SetIsFilterVisible(this DataGridColumn column, bool value) { if (column == null) { throw new ArgumentNullException("column"); } column.SetValue(DataGridFilterColumn.IsFilterVisibleProperty, (object)value); }
/// <summary> /// Control the visibility of the filter for this column. /// </summary> /// <param name="column">The column.</param> /// <param name="value">The value.</param> /// <exception cref="ArgumentNullException">column</exception> public static void SetIsFilterVisible(this DataGridColumn column, bool value) { if (column == null) { throw new ArgumentNullException(nameof(column)); } column.SetValue(IsFilterVisibleProperty, value); }
/// <summary> /// Sets the column tag on a <see cref="DataGridColumn"/>. /// </summary> /// <param name="column">The column to set the tag on.</param> /// <param name="value">The column tag.</param> public static void SetTag(this DataGridColumn column, Column value) { if (column == null) { throw new ArgumentNullException(nameof(column)); } column.SetValue(ColumnProperty, value); }
public static void TaskDataGridColumnSetLabelText(DataGridColumn col, string route, PropertyRoute context) { DependencyProperty labelText = DataGridColumn.HeaderProperty; if (labelText != null && col.NotSet(labelText)) { string text = context.PropertyInfo.NiceName(); UnitAttribute ua = context.PropertyInfo.GetCustomAttribute <UnitAttribute>(); if (ua != null) { text += " (" + ua.UnitName + ")"; } col.SetValue(labelText, text); } }
/// <summary> /// Examines the property path and returns the objects value for this column. /// Filtering is applied on the SortMemberPath, this is the path used to create the binding. /// </summary> internal static object?GetCellContentData(this DataGridColumn column, object?item) { var propertyPath = column.SortMemberPath; if (item == null || string.IsNullOrEmpty(propertyPath)) { return(null); } if (!(bool)column.GetValue(GetCellContentMustUseBindingProperty)) { try { var type = item.GetType(); var property = type.GetProperty(propertyPath); if (property != null) { return(property.GetValue(item)); } } catch { // not a plain property, fall-back to binding... } } column.SetValue(GetCellContentMustUseBindingProperty, true); // Since already the name "SortMemberPath" implies that this might be not only a simple property name but a full property path // we now use binding for evaluation; this will properly handle even complex property paths like e.g. "SubItems[0].Name" BindingOperations.SetBinding(column, CellValueProperty, new Binding(propertyPath) { Source = item }); var propertyValue = column.GetValue(CellValueProperty); BindingOperations.ClearBinding(column, CellValueProperty); return(propertyValue); }
/// <summary> /// Sets the filter expression of the column. /// </summary> /// <param name="column">The column.</param> /// <param name="value">The value.</param> public static void SetActiveFilter(this DataGridColumn column, IContentFilter?value) { column.SetValue(ActiveFilterProperty, value); }
public static void SetColumnId(DataGridColumn element, string value) { element.SetValue(ColumnIdProperty, value); }
/// <summary> /// Sets the filter expression of the column. /// </summary> public static void SetFilter(this DataGridColumn column, object value) { Contract.Requires(column != null); column.SetValue(FilterProperty, value); }
/// <summary> /// Sets the filter expression of the column. /// </summary> /// <param name="column">The column.</param> /// <param name="value">The value.</param> public static void SetFilter(this DataGridColumn column, object?value) { column.SetValue(FilterProperty, value); }
public static void SetSorter(DataGridColumn column, IComparer value) { column.SetValue(SorterProperty, value); }
/// <summary> /// The setter for the attached property. /// </summary> public static void SetCustomSort(DataGridColumn self, IColumnSorter value) { self.SetValue(CustomSortProperty, value); }
public static void SetCanUserHideColumn(DataGridColumn dataGridColumn, bool value) { dataGridColumn.SetValue(CanUserHideColumnProperty, value); }
public static void SetFormatForExport(DataGridColumn element, string value) { element.SetValue(FormatForExportProperty, value); }
/// <summary> /// Makes the column with have the specified initial sort /// </summary> /// <param name="column">The column</param> /// <param name="direction">The sort direction</param> /// <returns>The column</returns> public static DataGridColumn MakeInitialSort(this DataGridColumn column, ListSortDirection direction) { column.SetValue(DataGridColumns.SortDirectionProperty, direction); column.SortDirection = direction; return(column); }
/// <summary> /// Sets the selector name attached property for the column. /// </summary> /// <param name="column">The column</param> /// <param name="value">The selector name</param> /// <returns>The column</returns> public static DataGridColumn SetSelectorName(this DataGridColumn column, string value) { column.SetValue(DataGridColumns.SelectorNameProperty, value); return(column); }
/// <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); }
/// <summary> /// Sets the control template for the filter of this column. If the template is null or unset, a default template will be used. /// </summary> public static void SetTemplate(this DataGridColumn column, ControlTemplate value) { Contract.Requires(column != null); column.SetValue(TemplateProperty, value); }
/// <summary>Sets the filter expression of the column.</summary> /// <requires csharp="column != null" vb="column <> Nothing">column != null</requires> public static void SetFilter(this DataGridColumn column, object value) { // ISSUE: reference to a compiler-generated method __ContractsRuntime.Requires(column != null, (string)null, "column != null"); column.SetValue(DataGridFilterColumn.FilterProperty, value); }
/// <summary> /// Sets the control template for the filter of this column. If the template is null or unset, a default template will be used. /// </summary> /// <param name="column">The column.</param> /// <param name="value">The value.</param> public static void SetTemplate(this DataGridColumn column, ControlTemplate?value) { column.SetValue(TemplateProperty, value); }
public static void SetComparer(DataGridColumn element, IComparer value) { element.SetValue(ComparerProperty, value); }
public static void SetIsExported(DataGridColumn element, Boolean value) { element.SetValue(IsExportedProperty, value); }
public static void SetFilterTypeBinding(this DataGridColumn element, string value) { element.SetValue(FilterTypeProperty, value); }
private static void SetDataGridColumnSettings(DataGridColumn column, DataGridColumnSettings settings) { column.SetValue(DataGridColumnSettingsProperty, settings); }
/// <summary> /// Sets the filter host for the data grid of this column. /// </summary> /// <param name="column">The column.</param> /// <param name="value">The value.</param> public static void SetFilterHost(this DataGridColumn column, DataGridFilterHost?value) { column.SetValue(FilterHostProperty, value); }
public static void SetCustomComparer(DataGridColumn gridColumn, IDataGridColumnComparer value) { gridColumn.SetValue(CustomComparerProperty, value); }
/// <summary> /// Sets the filter host for the data grid of this column. /// </summary> /// <param name="column">The column.</param> /// <param name="value">The value.</param> public static void SetDataGridFilterColumnControl(this DataGridColumn column, DataGridFilterColumnControl?value) { column.SetValue(DataGridFilterColumnControlProperty, value); }
public static void SetCustomSorter(DataGridColumn gridColumn, ICustomSorter value) { gridColumn.SetValue(CustomSorterProperty, value); }
public static void SetExportString(DataGridColumn column, string value) { column.SetValue(ExportStringProperty, value); }