MVVM - Legend Label Binding

4 posts, 1 answers
  1. Icarus
    Icarus avatar
    2 posts
    Member since:
    Jan 2011

    Posted 21 Jan 2011 Link to this post

    Hi, 

    I am working with MVVM on a Telerik piechart

    I have a Dictionnary<string, int> which I would like to represent with a piechart. The value could easily be represented on the piechart but the problem is the keys of the dictionnary are not considered as legend labels. How can I fix this problem?

    <telerik:RadChart Margin="15,15,15,15" Grid.Row="0" Grid.Column="1"  HorizontalAlignment="Center" Background="Transparent" BorderThickness="0" FontSize="10" ItemsSource="{Binding Path=RightTopCollection}" >
        <telerik:RadChart.DefaultSeriesDefinition>
            <telerik:PieSeriesDefinition >
                <telerik:PieSeriesDefinition.InteractivitySettings >
                    <telerik:InteractivitySettings HoverScope="Item" SelectionScope="Item" SelectionMode="Single" />
                </telerik:PieSeriesDefinition.InteractivitySettings>
            </telerik:PieSeriesDefinition>
        </telerik:RadChart.DefaultSeriesDefinition>
    </telerik:RadChart>

    // In constructor
     this._RightTopCollection = new Dictionary<string, int>() {{"firstLabel", 4}, {"secondLabel", 25}, {"thirdLabel", 17}, {"fourthLabel", 19}, {" fifthLabel", 7} };
      
      
    // Class declaration
      #region RightTopCollection
            public const string RightTopCollectionPropertyName = "RightTopCollection";
            private Dictionary<string, int> _RightTopCollection = null;
            public Dictionary<string, int> RightTopCollection
            {
                get
                {
                    return _RightTopCollection;
                }
      
                set
                {
                    if (_RightTopCollection == value)
                    {
                        return;
                    }
      
                    var oldValue = _RightTopCollection;
                    _RightTopCollection = value;
      
                    // Update bindings, no broadcast
                    RaisePropertyChanged(RightTopCollectionPropertyName);
                }
            }
            #endregion

  2. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 27 Jan 2011 Link to this post

    Hi Icarus,

    Please review our demo which uses the MVVM pattern and will help you to get the idea of controlling the Legend Labels.
    I hope this gets you started properly.

    Regards,
    Evgenia
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. Answer
    Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 27 Jan 2011 Link to this post

    Hello Icarus,

    You can find a sample project attached demostrating a Pie chart databound using Manual Series Mappings.

    Best wishes,
    Evgenia
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  4. Icarus
    Icarus avatar
    2 posts
    Member since:
    Jan 2011

    Posted 28 Jan 2011 Link to this post

    It was exactly what I do need . Thank you.
Back to Top