(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

Tip: How to use enumeration as data source?

(0 votes)
Denislav Savkov
>
Denislav Savkov
Joined Feb 11, 2008
Articles:   14
Comments:   6
More Articles
1 comments   /   posted on Aug 29, 2008
Categories:   Data Binding


Currently there is no way to do that by using binding. Instead, you can make a List<> and add the values from the enumeration in the list. Then you can use this list as data source.

C#

List<Dock> enumDataSource = new List<Dock>() { Dock.Left, Dock.Top, Dock.Right, Dock.Bottom };
this.lbDock.ItemsSource = enumDataSource;

where lbDock is of type ListBox.

That's it!


Subscribe

Comments

  • -_-

    RE: Tip: How to use enumeration as data source?


    posted by Amr on May 25, 2009 20:11
    http://weblogs.asp.net/andrewrea/archive/2008/11/03/a-custom-dropdownlist-using-an-enum-type-as-a-datasource.aspx

Add Comment

Login to comment:
  *      *