将组合框绑定到字符串数组 (WPF)

Binding Combo Box to an array of string (WPF)

我正在尝试将组合框绑定到后面代码中的数组,如下所示:

private readonly string[] Bindlist ={..}
.
.
.
ComboBox newCombo = new ComboBox();
newCombo.ItemsSource = Bindlist ;

但是会抛出错误,无法从字符串转换为组合框项。

知道如何解决这个问题吗?

谢谢

我不知道你想做什么,但没问题;

public partial class MainWindow : Window
{

    private readonly string[] Bindlist = { "str1", "str2" };

    public MainWindow()
    {
        InitializeComponent();

        ComboBox box = new ComboBox();
        box.ItemsSource = Bindlist;

    }
}