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

Binding DataPointMember to a DependencyProperty

1 Answer 70 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Christoph
Top achievements
Rank 1
Christoph asked on 09 Dec 2010, 10:58 PM
Hi,
is it possible to bind the DataPointMember of a RadChart to a DependencyProperty of an object? In this particular case I want the bar height to change as soon as I change the value in the text box.

Here is some sample code:
RadChart1.ItemsSource = new TextBox[] { text };


<TextBox Name="text">2</TextBox>
<
telerik:RadChart x:Name="RadChart1" >
        <telerik:RadChart.SeriesMappings>
            <telerik:SeriesMapping LegendLabel="Test">              
                <telerik:SeriesMapping.ItemMappings>
                    <telerik:ItemMapping DataPointMember="YValue"  FieldName="Text" />                       
                    </telerik:SeriesMapping.ItemMappings>
            </telerik:SeriesMapping>
        </telerik:RadChart.SeriesMappings>
    </telerik:RadChart>

Thanks for your help.
Christoph

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 14 Dec 2010, 02:48 PM
Hello Christoph,

You can do this by creating an object that implements INotifyPropertyChanged and setting it to both RadChart and TextBox like this:

<telerik:RadChart x:Name="RadChart1" Margin="0,0,0,48" ItemsSource="{Binding}">
    <telerik:RadChart.SeriesMappings>
        <telerik:SeriesMapping>
            <telerik:SeriesMapping.SeriesDefinition>
                <telerik:BarSeriesDefinition />
            </telerik:SeriesMapping.SeriesDefinition>
            <telerik:ItemMapping FieldName="yValue" DataPointMember="YValue" />
        </telerik:SeriesMapping>
    </telerik:RadChart.SeriesMappings>
</telerik:RadChart>
<TextBox Height="23" HorizontalAlignment="Left" Margin="342,0,0,12" Name="textBox1" VerticalAlignment="Bottom" Width="120" Text="{Binding Path=[0].yValue, Mode=TwoWay}" />

In the attached file you can find a sample project that demonstrates this approach. Hope this helps!

All the best,
Yavor Ivanov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
Chart
Asked by
Christoph
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or