This is a migrated thread and some comments may be shown as answers.

Slider + Zoom.Width + RadCartesianChart

1 Answer 183 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 22 Oct 2015, 07:29 PM
I have a Slider control bound (TwoWay) to the Zoom.Width property of a RadCartesianChart control.  When I zoom in and out with the scrollwheel on my mouse, the Slider automatically changes (as it should).  But when I try to use the slider to zoom thechart in and out, nothing happens.  The slider won't move.  Is there something I am missing?

 

<Slider Name="Slider"
    Grid.Column="0"
    Margin="2"
    Orientation="Vertical"
    Minimum="1"
    Maximum="100"
    Value="{Binding ElementName=Chart, Path=Zoom.Width, Mode=TwoWay}"/>
 
<telerik:RadCartesianChart Name="Chart"
    Grid.Column="1"
    Palette="{Binding ChartPalette}"
    HorizontalZoomRangeStart="{Binding HorizontalZoomRangeStart, Mode=TwoWay}"
    HorizontalZoomRangeEnd="{Binding HorizontalZoomRangeEnd, Mode=TwoWay}">
 
    ...
 
</telerik:RadCartesianChart>

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 27 Oct 2015, 03:11 PM
Hi Kyle,

The Zoom property of the chart is of type Size which is a struct. This means that your binding gets a copy of struct since structs are passed by value to methods. In order to get the slider changing zoom's width of the chart attach to slider's ValueChanged event of the slider and update the WIdth and Height of the zoom.

For instance:
private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
    Chart.Zoom = new Size()
    {
        Width = this.Slider.Value,
        Height = this.Chart.Zoom.Height
    };
}
You can further customize the method and update the PanOffset as well.

Hope this helps.

Regards,
Peshito
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Kyle
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Share this question
or