/// <summary> /// Arrange Children based on their set relative position and size. /// </summary> protected override Size ArrangeOverride(Size finalSize) { if (Children == null || Children.Count == 0) { return(finalSize); } foreach (FrameworkElement child in Children) { double size = ScatterCanvas.GetSize(child); double tempHeight = finalSize.Height * size, tempWidth = finalSize.Width * size; if (tempHeight < 0 || tempWidth < 0) { continue; } if ((Stretch)child.GetValue(ScatterViewItem.StretchProperty) == Stretch.None) { tempHeight = child.DesiredSize.Height; tempWidth = child.DesiredSize.Width; } Point center = ScatterCanvas.GetCenter(child); Point pinPoint = ScatterCanvas.GetPinPoint(child); Point actualPinPoint = new Point(center.X * finalSize.Width - tempWidth * pinPoint.X, center.Y * finalSize.Height - tempHeight * pinPoint.Y); child.Arrange(new Rect(actualPinPoint, new Size(tempWidth, tempHeight))); } return(finalSize); }
/// <summary> /// Measure the Children with Positive infinity height and width. /// </summary> protected override Size MeasureOverride(Size constraint) { Size unconstrained = new Size(Double.PositiveInfinity, Double.PositiveInfinity); foreach (FrameworkElement child in Children) { double size = ScatterCanvas.GetSize(child); double tempHeight = constraint.Height * size, tempWidth = constraint.Width * size; if (tempHeight < 0 || tempWidth < 0) { continue; } if ((Stretch)child.GetValue(ScatterViewItem.StretchProperty) == Stretch.None) { tempHeight = Double.PositiveInfinity; tempWidth = Double.PositiveInfinity; } child.Measure(new Size(tempWidth, tempHeight)); } return(constraint); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); //_canvas = Template.FindName("PART_PANEL",this) as ScatterCanvas; _canvas = TreeHelper.FindDescendent(this, "PART_PANEL") as ScatterCanvas; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); //_canvas = Template.FindName("PART_PANEL",this) as ScatterCanvas; _canvas = TreeHelper.FindDescendent(this, "PART_PANEL") as ScatterCanvas; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); _canvas = Template.FindName("PART_PANEL",this) as ScatterCanvas; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); _canvas = Template.FindName("PART_PANEL", this) as ScatterCanvas; }