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
edit
ButtonEditThe editor to extend.
getEmptyValue
Func<object>Factory that returns a value to assign on clear. If
null
,null
will 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
editSettings
ComboBoxEditSettingsThe combo box editor settings to extend.
emptyValue
objectThe 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
cb
ComboBoxEditExThe combo box to read from.
Returns
- T
The current value cast to
T
.
Type Parameters
T
The expected value type.
GetSelecteds<T>(ComboBoxEditEx)
Gets the currently selected values as IEnumerable<T>.
public static IEnumerable<T> GetSelecteds<T>(this ComboBoxEditEx cb)
Parameters
cb
ComboBoxEditExThe combo box to read from.
Returns
- IEnumerable<T>
A sequence of selected values.
Type Parameters
T
The 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
edit
ButtonEditThe editor to modify.
SetItemsSource(ComboBoxEditEx, IItemsSource)
Assigns the specified IItemsSource to the combo box.
public static void SetItemsSource(this ComboBoxEditEx cb, IItemsSource source)
Parameters
cb
ComboBoxEditExThe combo box to modify.
source
IItemsSourceThe 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
cb
ComboBoxEditExThe combo box to populate.
enumType
TypeThe enum type to use as items.
Exceptions
- ArgumentNullException
Thrown when
cb
isnull
.- ArgumentException
Thrown when
enumType
is 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
cb
ComboBoxEditExThe combo box to populate.
Type Parameters
T
The 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
cb
ComboBoxEditExThe combo box to populate.
values
IEnumerable<T>The values to show.
getName
Func<T, string>Optional display name resolver.
getDescription
Func<T, string>Optional description resolver.
Type Parameters
T
The 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
cb
ComboBoxEditExThe combo box to modify.
value
TThe value to set.
Type Parameters
T
The 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
val
objectThe source value to wrap.
itemValueType
TypeType of values contained in the items source.
excludeObsolete
bool?Whether to exclude obsolete items. If
null
, the default behavior is used.sortOrder
ListSortDirection?Optional sort direction.
filter
Func<IItemsSourceItem, bool>Optional filter applied to items.
getName
Func<object, string>Optional display name resolver.
getDescription
Func<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
val
IEnumerable<T>Source sequence.
excludeObsolete
boolWhether to exclude obsolete items. Default is
true
.sortOrder
ListSortDirection?Optional sort direction.
filter
Func<IItemsSourceItem, bool>Optional filter predicate.
getName
Func<T, string>Optional display name resolver.
getDescription
Func<T, string>Optional description resolver.
Returns
- IItemsSource<T>
An IItemsSource<TValue> instance.
Type Parameters
T
The item value type.