Databinding an enum property to a ComboBox in WPF

后端 未结 13 1484
北海茫月
北海茫月 2020-11-22 15:46

As an example take the following code:

public enum ExampleEnum { FooBar, BarFoo }

public class ExampleClass : INotifyPropertyChanged
{
    private ExampleEn         


        
13条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 16:23

    I don't know if it is possible in XAML-only but try the following:

    Give your ComboBox a name so you can access it in the codebehind: "typesComboBox1"

    Now try the following

    typesComboBox1.ItemsSource = Enum.GetValues(typeof(ExampleEnum));
    

提交回复
热议问题