改善WPF / Telerik(Rad)TreeListView的滚动性能问题。

huangapple go评论69阅读模式
英文:

Improve WPF / telerik (Rad)TreeListView bad scrolling performance

问题

我在我的.NET 6 WPF应用程序中使用了一个telerik的RadTreeListView,在滚动过程中性能非常差。

使用滚轮时,更新可能需要2秒,快速拖动垂直滚动条会导致小于等于5秒的延迟。

我大约有350行数据,这些数据组织在单个顶级元素下。视图有5个手动定义的列。

我对性能进行了分析,发现几乎所有UI线程上花费的CPU时间都用于布局:

改善WPF / Telerik(Rad)TreeListView的滚动性能问题。

我尝试启用了虚拟化功能,使用了属性EnableRowVirtualizationEnableColumnGroupsVirtualizationEnableColumnVirtualization

我可以采取哪些步骤来提高滚动性能?

英文:

I use a telerik RadTreeListView in my .NET 6 WPF application and experience very bad performance during scrolling.

Updates when using the scroll wheel can take 2 seconds and dragging the vertical scroll bar quickly results in lag spikes of <=5 seconds.

I have about 350 rows which are organized under a single top-level element. The view has 5 manually defined columns.

I profiled the performance and saw that virtually all the CPU time spent on the UI thread is used for layouting:

改善WPF / Telerik(Rad)TreeListView的滚动性能问题。

I tried enabling the virtualizing functionality by using the attributes EnableRowVirtualization, EnableColumnGroupsVirtualization, EnableColumnVirtualization.

What steps can I take to improve my scroll performance?

Edit: Here is the XAML of an example project that illustrates my problem.

&lt;telerik:RadBusyIndicator Grid.Column=&quot;1&quot;  Grid.Row=&quot;1&quot;
                                              BusyContent=&quot;{Binding BusyReason}&quot; IsBusy=&quot;{Binding BusyReason, Converter={StaticResource stringEmptyConverter}}&quot; &gt;
            &lt;telerik:RadTreeListView  x:Name=&quot;treeView&quot; ItemsSource=&quot;{Binding Pages, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}&quot; 
                                                 AutoGenerateColumns=&quot;False&quot; AutoExpandItems=&quot;True&quot;
                                                 SelectedItem=&quot;{Binding SelectedPage}&quot;
                                                 PreviewMouseRightButtonDown=&quot;RadTreeListView_PreviewMouseRightButtonDown&quot; IsDragDropEnabled=&quot;False&quot;
                                      PreparedCellForEdit=&quot;treeView_PreparedCellForEdit&quot;
                                      BeginningEdit=&quot;treeView_BeginningEdit&quot;
                                      CanUserDeleteRows=&quot;False&quot;
                                      EnableRowVirtualization=&quot;True&quot;
                                      EnableColumnGroupsVirtualization=&quot;False&quot;
                                      EnableColumnVirtualization=&quot;False&quot;
                                      GroupRenderMode=&quot;Flat&quot;
                                      IsPropertyChangedAggregationEnabled=&quot;False&quot;
                                      &gt;
                &lt;telerik:RadTreeListView.ChildTableDefinitions&gt;
                    &lt;telerik:TreeListViewTableDefinition ItemsSource=&quot;{Binding ChildElements, Mode=TwoWay}&quot;/&gt;
                &lt;/telerik:RadTreeListView.ChildTableDefinitions&gt;
                &lt;telerik:RadTreeListView.Columns&gt;
                    &lt;telerik:GridViewDataColumn DataMemberBinding=&quot;{Binding Name, TargetNullValue=&#39;&#39;}&quot; Header=&quot;ID Name&quot;
                                                Width=&quot;Auto&quot; IsSortable=&quot;False&quot; IsFilterable=&quot;False&quot;/&gt;
                    &lt;telerik:GridViewComboBoxColumn  Header=&quot;ID&quot; DataMemberBinding=&quot;{Binding Id, Mode=TwoWay}&quot;
                                                IsSortable=&quot;False&quot; IsFilterable=&quot;False&quot;
                                                    ItemsSource=&quot;{Binding RelativeSource={RelativeSource AncestorType={x:Type telerik:RadTreeListView}}, Path=DataContext.Ids}&quot;
                                                     Width=&quot;100&quot;
                                                    x:Name=&quot;columnWarnId&quot;
                                                    IsLightweightModeEnabled=&quot;True&quot;
                                                     EmptyText=&quot;not set&quot;
                                                    &gt;
                        &lt;telerik:GridViewComboBoxColumn.EditorStyle&gt;
                            &lt;Style TargetType=&quot;telerik:RadComboBox&quot; BasedOn=&quot;{StaticResource RadComboBoxStyle}&quot;&gt;
                                &lt;Setter Property=&quot;OpenDropDownOnFocus&quot; Value=&quot;True&quot;/&gt;
                            &lt;/Style&gt;
                        &lt;/telerik:GridViewComboBoxColumn.EditorStyle&gt;
                        &lt;telerik:GridViewComboBoxColumn.ItemTemplate&gt;
                            &lt;DataTemplate DataType=&quot;{x:Type dt:DataObject}&quot;&gt;
                                &lt;telerik:Label Content=&quot;{Binding IdName}&quot;/&gt;
                            &lt;/DataTemplate&gt;
                        &lt;/telerik:GridViewComboBoxColumn.ItemTemplate&gt;
                    &lt;/telerik:GridViewComboBoxColumn&gt;
                    &lt;telerik:GridViewDataColumn DataMemberBinding=&quot;{Binding Ca, TargetNullValue=&#39;&#39;}&quot; Header=&quot;Foobar&quot;
                                                IsFilterable=&quot;False&quot; 
                                                Width=&quot;65&quot;
                                                x:Name=&quot;columnCa&quot;
                                                /&gt;
                    &lt;telerik:GridViewDataColumn DataMemberBinding=&quot;{Binding HasChanged, TargetNullValue=&#39;&#39;}&quot; Header=&quot;*&quot;
                                                IsFilterable=&quot;False&quot;
                                                IsReadOnly=&quot;True&quot;&gt;
                        &lt;telerik:GridViewDataColumn.CellTemplate&gt;
                            &lt;DataTemplate&gt;
                                &lt;TextBlock Visibility=&quot;{Binding HasChanged, Converter={helpers:BooleanToVisibilityConverter}}&quot; Text=&quot;*&quot;/&gt;
                            &lt;/DataTemplate&gt;
                        &lt;/telerik:GridViewDataColumn.CellTemplate&gt;
                    &lt;/telerik:GridViewDataColumn&gt;
                    &lt;telerik:GridViewDataColumn DataMemberBinding=&quot;{Binding WarningsPresent, TargetNullValue=&#39;&#39;}&quot; Header=&quot;Warning&quot;
                                                IsFilterable=&quot;False&quot;
                                                IsReadOnly=&quot;True&quot;&gt;
                        &lt;telerik:GridViewDataColumn.CellTemplate&gt;
                            &lt;DataTemplate&gt;
                                &lt;Image HorizontalAlignment=&quot;Center&quot; Visibility=&quot;{Binding WarningsPresent, Converter={helpers:BooleanToVisibilityConverter}}&quot;                                    Source=&quot;pack://application:,,,/Resources/Images/icons8-fehler-48.png&quot;
                                       Stretch=&quot;Uniform&quot; 
                                       MaxHeight=&quot;24&quot;/&gt;
                            &lt;/DataTemplate&gt;
                        &lt;/telerik:GridViewDataColumn.CellTemplate&gt;
                    &lt;/telerik:GridViewDataColumn&gt;
                &lt;/telerik:RadTreeListView.Columns&gt;
            &lt;/telerik:RadTreeListView&gt;
        &lt;/telerik:RadBusyIndicator&gt;

答案1

得分: 0

Telerik支持提供了反馈。

性能问题源于GridViewComboBoxColumn,在我的情况下,显示大约200个条目(每行都相同)。

这是一个已知问题,自2015年以来telerik并不认为它是一个bug。

根本原因是底层的RadComboBox即使没有扩展也会评估其内容。当我从我的RadTreeView中移除GridViewComboBoxColumn时,在_Debug_模式下性能提高到可接受水平,_Release_模式下性能良好。

上面链接的支持页面建议将ComboBox的项目重写为字典,以提高telerik内部的性能。

英文:

The telerik Support offered feedback.

The performance problem stems from the GridViewComboBoxColumn that - in my case - displays ~200 entries (the same for each row).

It's a known issue that is not considered a bug by telerik since 2015.

The root cause is that the underlying RadComboBox evaluates its contents even if it's not extended. When I removed the GridViewComboBoxColumn from my RadTreeView, performance jumped to acceptable levels in Debug mode and good performance in Release mode.

The support page linked above suggests rewriting the collection for the ComboBox' items to a dictionary so that telerik-internal performance is improved.

huangapple
  • 本文由 发表于 2023年4月19日 23:22:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76056257.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定