Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
576 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...