问题描述:

this is my code

<Canvas Name="chartCanvas1" ClipToBounds="True" Background="Beige">

<Canvas.RenderTransform>

<TransformGroup>

<ScaleTransform ScaleY="-1" />

<TranslateTransform Y="355" />

</TransformGroup>

</Canvas.RenderTransform>

</Canvas>

i need to bind the Y="355" to a value from the code behind class in runtime and convert the coordinate system to the natural coordinate system used in mathematics.

problem is i don't know how to do that.

some one please help me out.

regards,

rangana.

网友答案:

You could implement a IValueConverter for this that does your conversion between the two coordinate systems. And the bind to it in XAML:

<TranslateTransform Y="{Binding SomeDataProperty Converter={StaticResource myCoordinateConverter}}" />

Alternatively if you'd use MVVM your ViewModel would take the mathematical coordinate from the model, convert it to the WPF coordinate system an provide a property for that where the view (the XAML) can directly bind against.

相关阅读:
Top