简体   繁体   中英

Programmatically bind enum type to combobox

I have the following enum.

public enum DATABASE_TYPES
        {
            JDataStore, Access, SQLServer, H2, PostGresSQL, MySQL
        };

I would like to bind it to a WPF combo box.

I have tried:

cmb.ItemsSource = DATABASE_TYPES;

but get the error:

'ConfigGui.MainWindow.DATABASE_TYPES' is a 'type' but is used like a 'variable'

将其绑定到枚举的值:

cmb.ItemsSource = Enum.GetValues(typeof(DATABASE_TYPES)).Cast<DATABASE_TYPES>();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM