Binding DataPointMember to a DependencyProperty

2 posts, 0 answers
  1. Christoph
    Christoph avatar
    1 posts
    Member since:
    Nov 2010

    Posted 09 Dec 2010 Link to this post

    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
  2. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 14 Dec 2010 Link to this post

    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
Back to Top