【发布时间】:2011-06-08 02:43:44
【问题描述】:
从股票数据绑定应用程序开始,我有三个字符串:LineOne、LineTwo 和 LineThree。现在想象一下我有 IntThree 而不是 LineThree。
数据像这样添加到项目中:
this.Items.Add(new ItemViewModel() { LineOne = "runtime one", LineTwo = "Maecenas praesent accumsan bibendum", IntThree = 5 });
this.Items.Add(new ItemViewModel() { LineOne = "runtime two", LineTwo = "Dictumst eleifend facilisi faucibus", IntThree = 8 });
等等。
在我的主页中
<StackPanel Margin="0,0,0,17" Width="432">
<TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="{Binding IntTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
围绕 StackPanel 的列表框中项目的显示顺序取决于项目添加到“项目”的顺序。我计划有一个应用栏菜单,上面写着“按 LineOne 排序”、“按 IntThree 排序”等。有谁知道是否可以对此列表进行排序,然后刷新 UI。我该怎么做呢?我知道 ObservableCollections 可以在添加和删除时更新 UI,但这也适用于排序。我无法明确导航到同一页面。
感谢收看。
【问题讨论】: