Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
579 views
in Technique[技术] by (71.8m points)

c# - ListView with columns and bindings performance

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...