【发布时间】:2014-12-03 01:40:32
【问题描述】:
当我尝试更新 ListView 中插入元素的值时,我没有在手机上看到更改,但在调试消息中我看到了更改。这是我的代码。
private void chat_LayoutUpdated(object sender, object e)
{
foreach (Message item in chat.Items)
{
item.MessageTime = GetRelativeDate(item.MessageDateTime);
Debug.WriteLine(item.MessageTime); //Display changed value(Delta computed on step before) but on phone screen value didn't change;
}
}
GetRelativeDate // 返回当前时间与消息发送时间之间的差值的长函数。
class Message // Model of chat message
{
public string MessageText { get; set; }
public string MessageTime { get; set; } // This value i want to change in ListView.
public DateTime MessageDateTime { get; set; }
}
XAML
<TextBlock Grid.Column="0"
FontSize="22"
Text="{Binding MessageText}" />
<TextBlock
Grid.Column="1"
Grid.Row="1"
FontSize="10"
Text="{Binding MessageTime}" />
P/s 也许我需要更具体的东西来用作聊天窗口。
无论如何,谢谢大家,我将非常感谢任何答案或建议。
【问题讨论】:
标签: c# xaml listview windows-phone windows-phone-8.1