Silverlight 中datagrid控件-- 通过设置数据虚拟化加速显示

定义依赖属性作为datagrid的数据源

protected static readonly DependencyProperty ViewLogsProperty =
DependencyProperty.Register("ViewLogs", typeof(ObservableCollection<RMSReportEvent>), typeof(LogViewer), new PropertyMetadata(null));
protected ObservableCollection<RMSReportEvent> ViewLogs
{
get { return (ObservableCollection<RMSReportEvent>)GetValue(ViewLogsProperty); }
set { SetValue(ViewLogsProperty, value); }
}

页面进行绑定的同时,设置数据虚拟化

<data:DataGrid AutoGenerateColumns="False" AlternatingRowBackground="White" RowBackground="White"
  RowHeight="26" GridLinesVisibility="All" BorderThickness="0" ItemsSource="{TemplateBinding ViewLogs}"
  Margin="1" VirtualizingStackPanel.VirtualizationMode="Recycling">
  <data:DataGrid.Columns>
    ......

  </data:DataGrid.Columns>

</data:DataGrid>

posted @ 2015-05-26 13:10  TonyZhang24  阅读(204)  评论(0编辑  收藏  举报