Problem loading multiple user controls

My application loads a bunch of the same user control into ScrollPanel. The problem is that it is very slow.

The profiler shows that the method Application.LoadComponent()that is internally expressed in the constructor code in the constructor of my user control is a bottleneck. The documentation for this method says that this method loads the XAML files .

The question is, how can I use BAML instead of XAML? How can I ensure that the XAML for my user control should not be repeated over and over again when creating new instances from it? Is there a way to speed up the loading of my custom controls?

+3
source share
1 answer

LoadComponent()already loading .baml, do not worry about this issue. Microsoft did this intentionally so that developers did not make the dependence on the format baml. In the future, they can improve the format without breaking existing applications.

, . - . WPF VirtualizingStackPanel. ItemsControls (, , , ScrollViewer.CanContentScroll="False", ). , , , ItemsControl + DataBinding (ListBox )

, , .

. UserControls . . 10K , :

  • UserControl: 4932ms;
  • CustomControl: 86ms; (~ 57 )

,

+5

Source: https://habr.com/ru/post/1784303/


All Articles