This question is locked. New answers and comments are not allowed.
Hi,
I am testing the DataGrid control in order to use it in a project and I am wondering if the time that it takes to render the grid at the view when scrolling can be improved. It has a huge amount of data and it's just a few miliseconds but it would be great if this can be improved and none blank "gaps" appear.
Also, when I try to scroll and there is nothing to scroll, there is a bounce effect, is it possible to disable that?
Finally, is there a way of merging cells as it is done in WinForms?
Thanks,
James
01.<Page02. x:Class="App1.MainPage"04. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"05. xmlns:local="using:App1"06. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"07. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"08. xmlns:Grid="using:Telerik.UI.Xaml.Controls.Grid"09. mc:Ignorable="d">10. 11. <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">12. <Grid:RadDataGrid13. x:Name="Grid"14. CanDrag="False"15. UserColumnReorderMode="None"16. UserSortMode="None"17. ItemsSource="{Binding Rows}"18. AutoGenerateColumns="False"19. AllowDrop="False"20. SelectionMode="Single"21. SelectionUnit="Cell"22. UserGroupMode="Disabled"23. UserEditMode="None"24. UserFilterMode="Disabled"25. FrozenColumnCount="1"26. IncrementalLoadingMode="Auto"27. ScrollViewer.IsDeferredScrollingEnabled="False"28. ScrollViewer.IsHorizontalScrollChainingEnabled="True"29. ScrollViewer.IsVerticalScrollChainingEnabled="True"30. ScrollViewer.IsScrollInertiaEnabled="True"31. ScrollViewer.IsZoomChainingEnabled="False"32. ScrollViewer.ZoomMode="Disabled"33. ScrollViewer.VerticalScrollBarVisibility="Hidden"34. ScrollViewer.HorizontalScrollBarVisibility="Hidden"35. ManipulationMode="ScaleInertia"36. >37. </Grid:RadDataGrid>38. </Grid>39.</Page>
01.public sealed partial class MainPage : Page02. {03. public MainPage()04. {05. this.InitializeComponent();06. this.DataContext = new TestViewModel();07. InitGrid();08. }09. 10. public List<Row> Rows { get; set; }11. 12. private void InitGrid()13. {14. Rows = new List<Row>();15. for (int i = 0; i < 250; ++i) {16. Rows.Add(new Row());17. }18. 19. Random r = new Random();20. for (int i = 0; i < 250; ++i) {21. 22. StringBuilder sb = new StringBuilder();23. sb.Append("<DataTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">");24. sb.Append("<Grid Width=\"60\">");25. sb.Append("<TextBlock Margin=\"1\" HorizontalAlignment=\"Center\" Text=\"{Binding Path=Values[" + i.ToString() + "], Mode=OneWay}\" FontSize =\"18\" Foreground=\"Black\" />");26. sb.Append("</Grid>");27. sb.Append("</DataTemplate>");28. DataTemplate datatemplate = (DataTemplate)XamlReader.Load(sb.ToString());29. 30. var col = new DataGridTemplateColumn();31. col.Header = $"Column_{i}";32. col.CellContentTemplate = datatemplate;33. Grid.Columns.Add(col);34. }35. }36. }
01.public class TestViewModel02. {03. private Random random;04. 05. public List<Row> Rows { get; set; }06. 07. public TestViewModel()08. {09. random = new Random();10. Rows = new List<Row>();11. for (int i = 0; i < 250; ++i)12. {13. Rows.Add(new Row());14. }15. }16. 17. }18. public class Row19. {20. public Row() {21. var r = new Random();22. Values = new List<string>();23. for (int i = 0; i < 250; ++i)24. {25. string s = GenerateName(r.Next(7));26. Values.Add(s); 27. }28. }29. 30. public List<string> Values { get; set; }31. 32. private static string GenerateName(int len)33. {34. Random r = new Random();35. string[] consonants = { "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "l", "n", "p", "q", "r", "s", "t", "v", "w", "x" , "y", "z" };36. string[] vowels = { "a", "e", "i", "o", "u" };37. string Name = "";38. Name += consonants[r.Next(consonants.Length)].ToUpper();39. Name += vowels[r.Next(vowels.Length)];40. int b = 2;41. while (b < len)42. {43. Name += consonants[r.Next(consonants.Length)];44. b++;45. Name += vowels[r.Next(vowels.Length)];46. b++;47. }48. return Name;49. }50. }