WPF performance for a large number of items on the screen

I am currently trying to create a scene in WPF, where I have about 250 controls on the screen, and the user can move and zoom and resize these controls with the mouse.

I launched the WPF Performance Suite tools in the application when there are a large number of these controls on the screen (i.e. when the user zoomed out a little) the FPS drops to about 15, which is not very good.

Here is the main XAML outline:

<Window>
  <Window.Resources>
    <ControlTemplate x:Key="LandTemplate" TargetType="{x:Type local:LandControl}">
        <Canvas>
            <Path Fill="White" Stretch="Fill" Stroke="Black" StrokeThickness="1" Width="55.5" Height="74.687" Data="M0.5,0.5 L55,0.5 L55,74.187 L0.5,74.187 z"/>
            <Canvas x:Name="DetailLevelCanvas" Width="24.5" Height="21" Canvas.Left="15.306" Canvas.Top="23.972">
                <TextBlock Width="21" Height="14" Text="712" TextWrapping="Wrap" Foreground="Black"/>
                <TextBlock Width="17.5" Height="7" Canvas.Left="7" Canvas.Top="14" Text="614m2" TextWrapping="Wrap" FontSize="5.333" Foreground="Black"/>
            </Canvas>
        </Canvas>
    </ControlTemplate>
  </Window.Resources>

  ...
  <local:LandControl Width="55.5" Height="74.552" Canvas.Top="xxx" Template=" {StaticResource LandTemplate}" RenderTransformOrigin="0.5,0.5" Canvas.Left="xxx">
  <local:LandControl Width="55.5" Height="74.552" Canvas.Top="xxx" Template=" {StaticResource LandTemplate}" RenderTransformOrigin="0.5,0.5" Canvas.Left="xxx">
  <local:LandControl Width="55.5" Height="74.552" Canvas.Top="xxx" Template=" {StaticResource LandTemplate}" RenderTransformOrigin="0.5,0.5" Canvas.Left="xxx">
  <local:LandControl Width="55.5" Height="74.552" Canvas.Top="xxx" Template=" {StaticResource LandTemplate}" RenderTransformOrigin="0.5,0.5" Canvas.Left="xxx">
  ... and so on...
</Window>

Ive tried to minimize the details in the control template, and I even did a massive find and replace the controls to just add my original elements to the string instead of using the template, but without noticeable performance improvements.

SO- , , , , , , .

- , !

+3
2

, - .

. 4 , ZUI. , Atlas, , .

1) FrameworkElements - . FE GFX CPU 500-600 , . FE 10 .

2) . Robby Ingebretsens

3) Culling , / VisualTree . Collapsing/Hiding - .

4) WPF 3.5 2 : Visuals - Planerator, , , gfx.

5) WPF 4.0 , - Cached Composition. , Planerator. GFX .

4,0 - .CacheMode FrameworkElements, . , , , (EnableClearType RenderAtScale)

Atlas 700 + . 4 .

, . .

Kael Rowan ZoomableCanvas, . Quadtree PriorityQueue .

: 8-07-10 ZoomableCanvas

+10

Transformations , . , , , , , ... WPF , .


:

0

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


All Articles