tags:

views:

40

answers:

1

hi guys,

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.

+2  A: 

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.

bitbonk