WPF : 性能调整

  1. 2D Graphics and Imaging
    1. 尽量使用Drawing来代替Shape. 因为Drawing不用支持Layout和Event
    2. 尽量使用DrawingVisual来绘制背景等不需要Layout和Event的地方
    3. 使用图形时, 尽量decode到最小的size
    4. 在动画时, 调用RenderOptions.SetBitmapScalingMode()把图片设置到LowQuality
    5. 缓存Brush.
      // Set the minimum and maximum relative sizes for regenerating the tiled brush. RenderOptions.SetCacheInvalidationThresholdMinimum(drawingBrush, 0.5); RenderOptions.SetCacheInvalidationThresholdMaximum(drawingBrush, 2.0); // The tiled brush will be regenerated when the size is // 0.5x, 0.25x (and so forth) // and // 2x, 4x, 8x (and so forth) // of the original size. // Set the caching hint option for the brush. RenderOptions.SetCachingHint(drawingBrush, CachingHint.Cache);

你可能感兴趣的:(WPF)