keeping width and height equal

Dec 8, 2010 at 8:16 AM

Hi, 

 I need to keep the width and height of my plotter equal. I am plotting an IsolineGraph, where the units and max/min values on the x and y axes are equal. So far, to solve this problem, I have been using a Viewbox with a Uniform Stretch, but a lot of font sizing issues come along with this.

I have tried binding the Width/ actual width to the height /actual height of the graph with no success.

Any suggestions?

thanks......

Coordinator
Dec 9, 2010 at 6:38 AM
Hi Devora,

The first thought that came to me is to use the following binding:
plotter.SetBinding(HeightProperty, new Binding("ActualWidth") { Source = plotter });
This gives some result, but I don't think that this result if perfect.
The second thought was to put plotter into the following panel:
public class UniformPanel : Panel
{
protected override Size MeasureOverride(Size availableSize)
{
double min = Math.Min(availableSize.Width, availableSize.Height);
Size minSize = new Size(min, min);

foreach (UIElement item in InternalChildren)
{
item.Measure(minSize);
}

return minSize;
}

protected override Size ArrangeOverride(Size finalSize)
{
double min = Math.Min(finalSize.Width, finalSize.Height);
Size minSize = new Size(min, min);

foreach (UIElement item in InternalChildren)
{
item.Arrange(new Rect(minSize));
}

return minSize;
}
}

This approach works better.
--
Best regards,
Mikhail Brinchuk,
My freelance CV - searching for remote work
Jan 2, 2011 at 7:59 AM

I tried the panel, and it works, but I have to work out some issues......

What about using a PhysicalProportionsRestriction?

I have never used one before...

Thanks......