wpf 将文本绑定到父列表框的内容
我有一个列表框,其项目将以文本框格式显示,如下所示:-
<ListBox ItemsSource="{Binding movieList}" Name="innerList">
<ListBox.ItemTemplate >
<DataTemplate >
<TextBox Text="-------" TextChanged="TextBox_TextChanged_1"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
编辑:
抱歉,电影列表是(电影的)可观察集合,而不是(字符串)
如何让文本框显示的内容它的祖先(innerList)?
I have a listBox whose items are to be shown in a textbox format, like so:-
<ListBox ItemsSource="{Binding movieList}" Name="innerList">
<ListBox.ItemTemplate >
<DataTemplate >
<TextBox Text="-------" TextChanged="TextBox_TextChanged_1"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
EDIT:
Sorry, movie list was an observablecollection (of Movie) instead of being (of String)
How do I get the textbox to show the contents of its ancestor (the innerList) ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想在文本框中显示电影的标题,只需使用:(
假设列表中的项目是具有
Title
属性的对象)If you want to display the title of a movie in the TextBox, just use that:
(assuming the items in the list are objects with a
Title
property)来自绑定声明概述
所以下面应该可以做到。
From Binding Declarations Overview
So following should do it.