SHARE
TWEET

Untitled

a guest Jun 25th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Data
  2. {
  3.    private CollectionViewSource viewSource = new CollectionViewSource();
  4.  
  5.    public Data()
  6.    {
  7.      var items = new List<Item>();
  8.      // Create 1000 items
  9.      viewSource.Source = items;
  10.    }
  11.  
  12.    public ICollectionView View => viewSource.View;
  13. }
  14.  
  15. public class Item
  16. {
  17.    public string Description { get; set; } = "Text here";
  18.    public bool Bool { get; set; }
  19.    public int Value { get; set; }
  20.    public DateTime TimeStamp { get; set; }
  21.    public Test EnumValue { get; set; }
  22.    public static IEnumerable AvailableEnumValues =>
  23.              Enum.GetValues(typeof(Test));
  24. }
  25.  
  26. <DataGrid ItemsSource="{Binding View}"
  27.  EnableColumnVirtualization="True" EnableRowVirtualization="True"
  28.  VirtualizingPanel.IsContainerVirtualizable="False"
  29.  VirtualizingPanel.IsVirtualizing="True"
  30.  VirtualizingPanel.VirtualizationMode="Recycling"
  31.  VirtualizingPanel.IsVirtualizingWhenGrouping="True"
  32.  VirtualizingStackPanel.CacheLength="2,3"
  33.  VirtualizingStackPanel.CacheLengthUnit="Page"
  34.  VirtualizingStackPanel.ScrollUnit="Item">
  35.   <DataGrid.Columns>
  36.     <DataGridTextColumn Binding="{Binding Description}" Width="100"/>
  37.         <DataGridTextColumn Binding="{Binding Value}" Width="100"/>
  38.         <DataGridCheckBoxColumn Binding="{Binding Bool}" Width="100"/>
  39.         <DataGridComboBoxColumn SelectedItemBinding="{Binding EnumValue}"
  40.             ItemsSource="{x:Static local:Item.AvailableEnumValues}"
  41.             Width="100"/>
  42.         <DataGridTextColumn Binding="{Binding TimeStamp}" Width="100"/>
  43.      <!-- Repeat 5 columns above 5 times -->
  44.   </DataGrid.Columns>
  45. </DataGrid>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top