我有这个收藏
ObservableCollection<string> Urls { get; set; }
在我的数据上下文类中。我的列表框中有一个绑定:
<ListBox ItemsSource="{Binding Urls}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding .}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
数据显示在列表框中,两个相应的未显示的按钮以及添加和删除命令也可以工作,但是更改TextBox不会影响集合的内容。
我试过Mode=TwoWay绑定,但我认为它已经打开了。我尝试了其他一些选项,例如 Validate=OnPropertyChange,但是,仍然没有任何更新。
如何使TextBox模板化项目内部ListBox实际更新Urls数据上下文类的属性?