EnumItemsSourceBehavior Class
Binds a control’s ItemsSource property to an enumeration.
Namespace: DevExpress.Mvvm.UI
Assembly: DevExpress.Xpf.Core.v21.1.dll
NuGet Package: DevExpress.Wpf.Core
Declaration
[TargetType(typeof(ListBoxEdit))]
[TargetType(typeof(ItemsControl))]
[TargetType(typeof(LookUpEditBase))]
public class EnumItemsSourceBehavior :
Behavior<FrameworkElement>
Remarks
You can use any of the following attributes with enumeration members:
The following code sample assigns the UserRole enumeration to the ComboBoxEdit‘s ItemsSource property:
<UserControl ...
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors">
<Grid>
<dxe:ComboBoxEdit>
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EnumItemsSourceBehavior EnumType="{x:Type common:UserRole}"/>
</dxmvvm:Interaction.Behaviors>
</dxe:ComboBoxEdit>
</Grid>
</UserControl>
public enum UserRole {
[Image("pack://application:,,,/Images/Admin.png"), Display(Name = "Admin", Description = "High level of access", Order = 1)]
Administrator,
[Image("pack://application:,,,/Images/Moderator.png"), Display(Name = "Moderator", Description = "Average level of access", Order = 2)]
Moderator,
[Image("pack://application:,,,/Images/User.png"), Display(Name = "User", Description = "Low level of access", Order = 3)]
User
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the EnumItemsSourceBehavior class.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.