Есть custom panel. На ней 4 элемента. На winXP все прорисовывается на ходу. На Win7 с тормозами, в чем может быть причина?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MyNamespace
{
public class Panel4View : Panel
{
private double _mainWindowWidth = 0;
private const double _margin = 5;
protected override Size MeasureOverride(Size availableSize)
{
double curX = 0;
double curY = 0;
foreach (UIElement child in Children)
{
if (((System.Windows.Forms.Integration.WindowsFormsHost)child).Name == _mainHostName)
{
if (availableSize.Height < availableSize.Width)
{
_mainWindowWidth = availableSize.Height - _margin;
child.Measure(new Size(_mainWindowWidth, _mainWindowWidth));
}
else
{
_mainWindowWidth = availableSize.Width * 0.7 - _margin;
child.Measure(new Size(_mainWindowWidth, _mainWindowWidth));
}
curX += child.DesiredSize.Width;
}
else
{
double width = availableSize.Width - _mainWindowWidth - _margin;
double height = (_mainWindowWidth - 2 * _margin) / 3;
child.Measure(new Size(width, height));
}
}
return availableSize;
}
protected override Size ArrangeOverride(Size finalSize)
{
if (this.Children == null || this.Children.Count == 0)
return finalSize;
double curX = 0;
double curY = 0;
foreach (UIElement child in Children)
{
if (((System.Windows.Forms.Integration.WindowsFormsHost)child).Name == _mainHostName)
{
child.Arrange(new Rect(0, 0, child.DesiredSize.Width, child.DesiredSize.Height));
curX += child.DesiredSize.Width;
}
else
{
child.Arrange(new Rect(curX + _margin, curY, child.DesiredSize.Width, child.DesiredSize.Height));
curY += child.DesiredSize.Height + _margin;
}
}
return finalSize;
}
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
MeasureOverride(sizeInfo.NewSize);
ArrangeOverride(sizeInfo.NewSize);
}
}
}