Class EditorExtensions
Extension methods for DevExpress editors and related helpers used across WPF UI.
public static class EditorExtensions
- Inheritance
-
EditorExtensions
- Inherited Members
Methods
AddClearButton(ButtonEdit, Func<object>)
Adds a clear (reset) button to the specified editor. When clicked, it sets the editor's DevExpress.Xpf.Editors.BaseEdit.EditValueProperty to the value returned by getEmptyValue.
public static void AddClearButton(this ButtonEdit edit, Func<object> getEmptyValue = null)
Parameters
editButtonEditThe editor to extend.
getEmptyValueFunc<object>Factory that returns a value to assign on clear. If
null,nullwill be assigned.
AddClearButton(ComboBoxEditSettings, object)
Adds a clear (reset) button to the specified DevExpress.Xpf.Editors.Settings.ComboBoxEditSettings. When clicked, it sets the owning editor's value to emptyValue.
public static void AddClearButton(this ComboBoxEditSettings editSettings, object emptyValue = null)
Parameters
editSettingsComboBoxEditSettingsThe combo box editor settings to extend.
emptyValueobjectThe value to assign on clear. Defaults to
null.
GetSelected<T>(ComboBoxEditEx)
Gets the currently selected value cast to T.
public static T GetSelected<T>(this ComboBoxEditEx cb)
Parameters
cbComboBoxEditExThe combo box to read from.
Returns
- T
The current value cast to
T.
Type Parameters
TThe expected value type.
GetSelecteds<T>(ComboBoxEditEx)
Gets the currently selected values as IEnumerable<T>.
public static IEnumerable<T> GetSelecteds<T>(this ComboBoxEditEx cb)
Parameters
cbComboBoxEditExThe combo box to read from.
Returns
- IEnumerable<T>
A sequence of selected values.
Type Parameters
TThe item type.
RemoveClearButton(ButtonEdit)
Removes a previously added clear (reset) button from the specified editor, if present.
public static void RemoveClearButton(this ButtonEdit edit)
Parameters
editButtonEditThe editor to modify.
SetItemsSource(ComboBoxEditEx, IItemsSource)
Assigns the specified IItemsSource to the combo box.
public static void SetItemsSource(this ComboBoxEditEx cb, IItemsSource source)
Parameters
cbComboBoxEditExThe combo box to modify.
sourceIItemsSourceThe items source to assign.
SetItemsSource(ComboBoxEditEx, Type)
Sets the items source of the combo box to all values of the specified enumType.
public static void SetItemsSource(this ComboBoxEditEx cb, Type enumType)
Parameters
cbComboBoxEditExThe combo box to populate.
enumTypeTypeThe enum type to use as items.
Exceptions
- ArgumentNullException
Thrown when
cbisnull.- ArgumentException
Thrown when
enumTypeis not an enum.
SetItemsSource<T>(ComboBoxEditEx)
Sets the items source of the combo box to all values of the specified enum type T.
public static void SetItemsSource<T>(this ComboBoxEditEx cb) where T : Enum
Parameters
cbComboBoxEditExThe combo box to populate.
Type Parameters
TThe enum type.
SetItemsSource<T>(ComboBoxEditEx, IEnumerable<T>, Func<T, string>, Func<T, string>)
Sets the items source of the combo box to the provided values.
public static void SetItemsSource<T>(this ComboBoxEditEx cb, IEnumerable<T> values, Func<T, string> getName = null, Func<T, string> getDescription = null)
Parameters
cbComboBoxEditExThe combo box to populate.
valuesIEnumerable<T>The values to show.
getNameFunc<T, string>Optional display name resolver.
getDescriptionFunc<T, string>Optional description resolver.
Type Parameters
TThe item type.
SetSelected<T>(ComboBoxEditEx, T)
Sets the current value of the combo box.
public static void SetSelected<T>(this ComboBoxEditEx cb, T value)
Parameters
cbComboBoxEditExThe combo box to modify.
valueTThe value to set.
Type Parameters
TThe value type.
ToItemsSource(object, Type, bool?, ListSortDirection?, Func<IItemsSourceItem, bool>, Func<object, string>, Func<object, string>)
Converts the specified value to an IItemsSource using the provided item type and optional filters.
public static IItemsSource ToItemsSource(this object val, Type itemValueType, bool? excludeObsolete = null, ListSortDirection? sortOrder = null, Func<IItemsSourceItem, bool> filter = null, Func<object, string> getName = null, Func<object, string> getDescription = null)
Parameters
valobjectThe source value to wrap.
itemValueTypeTypeType of values contained in the items source.
excludeObsoletebool?Whether to exclude obsolete items. If
null, the default behavior is used.sortOrderListSortDirection?Optional sort direction.
filterFunc<IItemsSourceItem, bool>Optional filter applied to items.
getNameFunc<object, string>Optional display name resolver.
getDescriptionFunc<object, string>Optional description resolver.
Returns
- IItemsSource
An IItemsSource instance.
ToItemsSource<T>(IEnumerable<T>, bool, ListSortDirection?, Func<IItemsSourceItem, bool>, Func<T, string>, Func<T, string>)
Wraps the specified sequence into an IItemsSource<TValue> with optional filtering and sorting.
public static IItemsSource<T> ToItemsSource<T>(this IEnumerable<T> val, bool excludeObsolete = true, ListSortDirection? sortOrder = null, Func<IItemsSourceItem, bool> filter = null, Func<T, string> getName = null, Func<T, string> getDescription = null)
Parameters
valIEnumerable<T>Source sequence.
excludeObsoleteboolWhether to exclude obsolete items. Default is
true.sortOrderListSortDirection?Optional sort direction.
filterFunc<IItemsSourceItem, bool>Optional filter predicate.
getNameFunc<T, string>Optional display name resolver.
getDescriptionFunc<T, string>Optional description resolver.
Returns
- IItemsSource<T>
An IItemsSource<TValue> instance.
Type Parameters
TThe item value type.