C# WPF bind IEnumerable中的自动完成文本框
我在家里找到了一个图书馆 但我坚持在第三步 创建一个文本框并将自动完成项资源绑定到IEnumerable的集合 我试着在 但还是不行,我不知道问题出在哪里 这是我的密码C# WPF bind IEnumerable中的自动完成文本框,c#,wpf,textbox,ienumerable,C#,Wpf,Textbox,Ienumerable,我在家里找到了一个图书馆 但我坚持在第三步 创建一个文本框并将自动完成项资源绑定到IEnumerable的集合 我试着在 但还是不行,我不知道问题出在哪里 这是我的密码 谢谢大家! 我浏览了你的代码,尝试一下这些更改,我想它会对你有用的 public partial class MainWindow : Window { public MainWindow() { this.DataContext = this;
谢谢大家! 我浏览了你的代码,尝试一下这些更改,我想它会对你有用的
public partial class MainWindow : Window
{
public MainWindow()
{
this.DataContext = this;
InitializeComponent();
TestItems = new ObservableCollection<string>()
{
"Apple",
"Banana",
"Carrot",
"Dog",
"Elderberry",
"Fruit",
"Grapes",
"Honey",
"Iron"
};
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
Person[] peopleArray = new Person[3]
{
new Person("John"),
new Person("Jim"),
new Person("Sue"),
};
People peopleList = new People(peopleArray);
foreach (Person p in peopleList)
Console.WriteLine(p.Name);
Console.ReadLine();
}
private ObservableCollection<string> testItems ;
public ObservableCollection<string> TestItems
{
get { return testItems; }
set
{
testItems= value;
OnPropertyChanged("TestItems");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler == null) return;
handler(this, new PropertyChangedEventArgs(name));
}
}
你能详细描述一下你的问题是什么吗?我是一个C初学者,喜欢实现文本框自动完成功能,我正在寻找简单或容易的方法来实现,忘了我我的英语不好。