我正在尝试构建一个“评论控件”(在类似于 Silverlight 的 win8 XAML 应用程序中),它将为用户加载和呈现评论树。
每个评论可以有 0 个或 1+ 个子评论(通过每个评论递归)。
每条评论都会显示一组信息,包括作者、时间、评论本身等。
我最初用来构建它的方法是使用具有“CommentItem”控件绑定的 ListView。
<TextBlock Grid.Row="1" TextWrapping="Wrap" Text="{Binding commentText}" FontSize="11" FontFamily="Global User Interface" />
<ListView Grid.Row="2" x:Name="CommentRepliesList" ItemsSource="{Binding}" >
<ListView.ItemTemplate>
<DataTemplate>
<local:CommentItem Tag="{Binding}"></local:CommentItem>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
上面将递归每个评论,应用评论文本,然后为每个评论子创建一个新的评论项,再次递归,等等。
但是,问题是这非常缓慢且性能不佳。
有谁知道更有效的方法来做到这一点?ListView 是用于此的适当控件吗?