EditorExtensions

Ecng.Xaml

Extension methods for DevExpress editors and related helpers used across WPF UI.

Methods

AddClearButton
public static void AddClearButton(ButtonEdit edit, Func<object> getEmptyValue)
EditorExtensions.AddClearButton(edit, getEmptyValue)

Adds a clear (reset) button to the specified editor. When clicked, it sets the editor's EditValueProperty to the value returned by .

edit
The editor to extend.
getEmptyValue
Factory that returns a value to assign on clear. If null, null will be assigned.
AddClearButton
public static void AddClearButton(ComboBoxEditSettings editSettings, object emptyValue)
EditorExtensions.AddClearButton(editSettings, emptyValue)

Adds a clear (reset) button to the specified ComboBoxEditSettings. When clicked, it sets the owning editor's value to .

editSettings
The combo box editor settings to extend.
emptyValue
The value to assign on clear. Defaults to null.
GetSelecteds``1
public static IEnumerable<T> GetSelecteds<T>(ComboBoxEditEx cb)
result = EditorExtensions.GetSelecteds(cb)

Gets the currently selected values as IEnumerable.

cb
The combo box to read from.

Returns: A sequence of selected values.

GetSelected``1
public static T GetSelected<T>(ComboBoxEditEx cb)
result = EditorExtensions.GetSelected(cb)

Gets the currently selected value cast to .

cb
The combo box to read from.

Returns: The current value cast to .

RemoveClearButton
public static void RemoveClearButton(ButtonEdit edit)
EditorExtensions.RemoveClearButton(edit)

Removes a previously added clear (reset) button from the specified editor, if present.

edit
The editor to modify.
SetItemsSource
public static void SetItemsSource(ComboBoxEditEx cb, Type enumType)
EditorExtensions.SetItemsSource(cb, enumType)

Sets the items source of the combo box to all values of the specified .

cb
The combo box to populate.
enumType
The enum type to use as items.
SetItemsSource
public static void SetItemsSource(ComboBoxEditEx cb, IItemsSource source)
EditorExtensions.SetItemsSource(cb, source)

Assigns the specified IItemsSource to the combo box.

cb
The combo box to modify.
source
The items source to assign.
SetItemsSource``1
public static void SetItemsSource<T>(ComboBoxEditEx cb)
EditorExtensions.SetItemsSource(cb)

Sets the items source of the combo box to all values of the specified enum type .

cb
The combo box to populate.
SetItemsSource``1
public static void SetItemsSource<T>(ComboBoxEditEx cb, IEnumerable<T> values, Func<T, string> getName, Func<T, string> getDescription)
EditorExtensions.SetItemsSource(cb, values, getName, getDescription)

Sets the items source of the combo box to the provided values.

cb
The combo box to populate.
values
The values to show.
getName
Optional display name resolver.
getDescription
Optional description resolver.
SetSelected``1
public static void SetSelected<T>(ComboBoxEditEx cb, T value)
EditorExtensions.SetSelected(cb, value)

Sets the current value of the combo box.

cb
The combo box to modify.
value
The value to set.
ToItemsSource
public static IItemsSource ToItemsSource(object val, Type itemValueType, bool? excludeObsolete, ListSortDirection? sortOrder, Func<IItemsSourceItem, bool> filter, Func<object, string> getName, Func<object, string> getDescription)
result = EditorExtensions.ToItemsSource(val, itemValueType, excludeObsolete, sortOrder, filter, getName, getDescription)

Converts the specified value to an IItemsSource using the provided item type and optional filters.

val
The source value to wrap.
itemValueType
Type of values contained in the items source.
excludeObsolete
Whether to exclude obsolete items. If null, the default behavior is used.
sortOrder
Optional sort direction.
filter
Optional filter applied to items.
getName
Optional display name resolver.
getDescription
Optional description resolver.

Returns: An IItemsSource instance.

ToItemsSource``1
public static IItemsSource<T> ToItemsSource<T>(IEnumerable<T> val, bool excludeObsolete, ListSortDirection? sortOrder, Func<IItemsSourceItem, bool> filter, Func<T, string> getName, Func<T, string> getDescription)
result = EditorExtensions.ToItemsSource(val, excludeObsolete, sortOrder, filter, getName, getDescription)

Wraps the specified sequence into an IItemsSource with optional filtering and sorting.

val
Source sequence.
excludeObsolete
Whether to exclude obsolete items. Default is true.
sortOrder
Optional sort direction.
filter
Optional filter predicate.
getName
Optional display name resolver.
getDescription
Optional description resolver.

Returns: An IItemsSource instance.