Hi.
We are using large XamGrid. And we have performance problems.I create Sample. (@v13.1 XamGrid.)
<Grid x:Name="LayoutRoot" Background="White"> <Grid.RowDefinitions> <RowDefinition Height="30"></RowDefinition> <RowDefinition Height="*"></RowDefinition> </Grid.RowDefinitions> <StackPanel Orientation="Horizontal"> <TextBlock Text="Rows" VerticalAlignment="Center"></TextBlock> <TextBox x:Name="maxcol" Text="40" VerticalAlignment="Center"></TextBox> <TextBlock Text="Columns" VerticalAlignment="Center"></TextBlock> <TextBox x:Name="maxrow" Text="40" VerticalAlignment="Center"></TextBox> <Button x:Name="button" Width="110">Refresh</Button> <TextBlock x:Name="res" Width="110" VerticalAlignment="Center"></TextBlock> </StackPanel> <ig:XamGrid x:Name="grid" Grid.Row="1" AutoGenerateColumns="False" HeaderRowHeight="Dynamic" Width="1600" Height="730"> <ig:XamGrid.Columns> </ig:XamGrid.Columns> </ig:XamGrid> </Grid>
void button_Click(object sender, RoutedEventArgs e){
//Clear Defenision this.grid.Columns.Clear(); foreach (var x in this.grid.Rows) { this.grid.Rows.Remove(x); }
var cnt = int.Parse(this.maxcol.Text);
//Create test columns for (var i = 0; i < cnt; i++) { var col = new TextColumn(); col.IsReadOnly = true;
col.Key = "[Column" + i.ToString() + "]"; col.Width = new ColumnWidth(60, false); this.grid.Columns.Add(col); }
//Create test rows var resource = new ObservableCollection<Dictionary<string,object>>(); var cntrow = int.Parse(this.maxrow.Text); for (var i = 0; i < RowCountSetting; i++) { var item = new Dictionary<string, object>(); for (var j = 0; j < cntrow; j++) { item.Add("Column" + j.ToString(), "test"); } resource.Add(item); } this.grid.ItemsSource = resource;
//Measure refresh rate var ticks = DateTime.Now.Ticks; this.UpdateLayout(); var ellapsedMilliseconds = (DateTime.Now.Ticks - ticks) /10000;
//Display result res.Text = (ellapsedMilliseconds).ToString() + "[ms]";
}
This program shows about 676 cells.
And use virtualization. but takes time to refresh.(over 1000ms)
Shoud I reduce cells?
Please tell me how gain refresh rate.
Hello and thank you for posting!
I have reviewed the provided code snippet and it seems that the columns and rows are cleared and then re-added to the grid on button click. This will force the visual elements of the grid to re-load. The rendering of the visuals mostly depends on the Silverlight rendering system and there is less things we can do to improve that.
You can try rendering less cells in view or updating the underlying data values instead of clearing the items (if the scenario allows it).
I would also suggest you using the latest released version in order to make sure the latest improvements for the control are included.
Hi Maria.
I delete cleared and re-added snnipet.
But there is no difference in rendering speed.
Maybe this is necessary expense...
Thanks for replying back :)
Hi,
You are welcome. Feel free to let me know if I could be of further assistance.