Hi I have a simple requirement. I am given the task to show a Couple of PolyLines on an XY Axis that scale well on any screen and can show any range of data.
So I created PloyLines and Added scaling transform on them using the Screen Size and the Maximum value at the time.
XAML- Basically a straight line, added for simplicity, can be complex equations curves
<Polyline Name="Line45" Points="0,0 1,1 2,2 3,3 4,4 5,5 6,6 7,7 8,8 9,9 10,10 11,11 12,12 13,13 14,14 15,15 16,16 17,17 18,18 19,19 20,20 "
Stroke="Blue" StrokeThickness="10">
<Polyline.LayoutTransform>
<ScaleTransform ScaleY="{Binding ScaleY,Mode=TwoWay}" ScaleX="{Binding ScaleX,Mode=TwoWay}"/>
</Polyline.LayoutTransform>
</Polyline>
Code Behind
private void Canvas_SizeChanged(object sender, SizeChangedEventArgs e)
{
vm.ScaleCanvas(e.NewSize, e.PreviousSize);
}
And ViewModel
public void ScaleCanvas(Size thisNewSize, Size thisOldSize)
{
NewSize = thisNewSize;
ScaleY = thisNewSize.Height / MaxLimitY;
ScaleX = thisNewSize.Width / MaxLimitX;
}
Now my requirement is to add dynamically scaling XY Axis so I can Plot from 0 to MaxLimitX
and 0 to MaxLimitY
.
I have No Idea how to proceed. Any ideas will be helpful. Thanks in advance.