public ChildMeasureCalledBorder() { Child = new ChildBorder(); ChildBorder.SetMeasureOverrideCalled = true; MeasureOverride(new Size(double.PositiveInfinity, double.PositiveInfinity)); ChildBorder.SetMeasureOverrideCalled = false; Assert.IsTrue(ChildBorder.MeasureOverrideCalled); }
protected override Size MeasureOverride(Size availableSize) { // Code in this method has been copied from the implementation // in the Silverlight 3 toolkitunder the MS-PL license: http://silverlight.codeplex.com/ Size size = new Size(); if (Child != null) { // Get the child's desired size ChildBorder.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Size desiredSize = ChildBorder.DesiredSize; // Determine how much we should scale the child Size scale = ComputeScaleFactor(availableSize, desiredSize); // Determine the desired size of the Viewbox size.Width = scale.Width * desiredSize.Width; size.Height = scale.Height * desiredSize.Height; } return(size); }
protected override Size ArrangeOverride(Size finalSize) { // Code in this method has been copied from the implementation // in the Silverlight 3 toolkitunder the MS-PL license: http://silverlight.codeplex.com/ if (Child != null) { // Determine the scale factor given the final size Size desiredSize = ChildBorder.DesiredSize; Size scale = ComputeScaleFactor(finalSize, desiredSize); // Scale the Border by the necessary factor Scale.ScaleX = scale.Width; Scale.ScaleY = scale.Height; // Position the Child to fill the ChildBorder Rect originalPosition = new Rect(0, 0, desiredSize.Width, desiredSize.Height); ChildBorder.Arrange(originalPosition); // Determine the final size used by the Viewbox finalSize.Width = scale.Width * desiredSize.Width; finalSize.Height = scale.Height * desiredSize.Height; } return(finalSize); }
public ChildMeasureCalledBorder () { Child = new ChildBorder (); ChildBorder.SetMeasureOverrideCalled = true; MeasureOverride (new Size (double.PositiveInfinity, double.PositiveInfinity)); ChildBorder.SetMeasureOverrideCalled = false; Assert.IsTrue (ChildBorder.MeasureOverrideCalled); }