I have performance issue with ListView
:
Single item takes 13-30 ms to create (50 items is over 1 second). Virtualization (recyling mode) is on, but scrolling even 100 items is already very uncomfortable.
At first I thought it's layout problem. But the reason seems to be - bindings.
There are multiple columns and each column cell has different template with different bindings, as an example:
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding Value}"
Visibility="{Binding IsEditable, Converter={local:TrueToCollapsedConverter}}" />
<Grid local:GridBehavior.Columns=",auto"
Visibility="{Binding IsEditable, Converter={local:FalseToCollapsedConverter}}">
<TextBox Text="{local:ExceptionBinding Path=Value, Converter={local:DoubleToStringConverter}}"
local:TextBoxBehavior.SelectAllOnFocus="True"
local:ListBoxBehavior.SelectListBoxItemOnFocus="True" />
<TextBlock Grid.Column="1" Text="{local:Lng Key=Unit.mm}" />
</Grid>
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
Any single binding add something like 0.1 ms. There are 20 columns, each cell has from 1 to 20 bindings, so it leads to this:
Binding take majority of time, e.g. 2.83 of 3.07 ms for the first column on screenshot.
Is there a way to gain some performance? Am I doing some obvious mistake?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…