wpf将文本绑定到父列表框';内容
我有一个列表框,其项目将以文本框格式显示,如下所示:-wpf将文本绑定到父列表框';内容,wpf,vb.net,xaml,binding,ancestor,Wpf,Vb.net,Xaml,Binding,Ancestor,我有一个列表框,其项目将以文本框格式显示,如下所示:- <ListBox ItemsSource="{Binding movieList}" Name="innerList"> <ListBox.ItemTemplate > <DataTemplate > <TextBox Text="-------" TextChanged="TextBox_TextChanged_1"/>
<ListBox ItemsSource="{Binding movieList}" Name="innerList">
<ListBox.ItemTemplate >
<DataTemplate >
<TextBox Text="-------" TextChanged="TextBox_TextChanged_1"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
编辑:
抱歉,电影列表是(电影的)可观察集合,而不是(字符串的)
如何让文本框显示其祖先(内部列表)的内容?如果要在文本框中显示电影的标题,只需使用该选项:
<TextBox Text="{Binding Title}" TextChanged="TextBox_TextChanged_1"/>
(假设列表中的项目是具有标题
属性的对象)来自
或者,可以使用句点(.)路径绑定到当前
来源。例如,Text=“{Binding}”等同于Text=“{Binding}”
路径=。}”
所以下面应该做
<TextBox Text="{Binding}" TextChanged="TextBox_TextChanged_1"/>
实际上,我不确定我是否正确理解了您的问题。。。你到底想在文本框中显示什么?movieList的内容。他们没有使用任何项目模板工作,但我需要他们是可编辑的这是不够精确。。。是否要在同一文本框中显示所有电影?或者,是否要在不同的文本框中显示每部电影的标题(或其他属性)?是的,列表框(每部电影)的每个项目都应显示为单独的文本框。不起作用:(我尝试了movieList和innerList。如果没有itemTemplates,我只需要它们是可编辑的,所以我使用了TextBox抱歉,movie list是一个可观察的集合(电影),它们不起作用。我尝试了Text=“{Binding}”Text=“{Binding Path=。}”和Text=“{Binding.}”