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>

转载于:https://www.cnblogs.com/atuotuo/p/4530372.html

评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符 “速评一下”
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页