【发布时间】:2013-09-30 10:25:09
【问题描述】:
我有一个列表框,其项目模板是用户控件:
<ListBox
x:Name="ChatBox"
Width="450"
ItemsSource="{Binding ChatMessage}">
<ListBox.ItemTemplate>
<DataTemplate>
<local:ChatItem DataContext="{Binding ChatMessage}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
在我的代码后面:
messages = new ObservableCollection<ChatMessage>(dbMessages);
ChatBox.ItemsSource = messages;
如何从控件内部获取绑定元素,即聊天消息对象?
感谢您的帮助
【问题讨论】:
-
您是否也在代码隐藏中设置了 ItemSource?你能把你的 C# 代码也贴上来让我们看看吗?
标签: c# windows-phone-7 data-binding user-controls windows-phone