rad chart title binding

10 posts, 0 answers
  1. rooma
    rooma avatar
    5 posts
    Member since:
    Aug 2011

    Posted 07 Oct 2011 Link to this post

    Hello ,
    I am trying to  bind my rad chart title to a string in view model.

     

     

    <telerik:ChartDefaultView.ChartTitle>

     

     

    <telerik:ChartTitle Content= "{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type views:PlotView}},Path=DataContext.ChartTitle}" HorizontalAlignment="Center"/>

     

     

    </telerik:ChartDefaultView.ChartTitle>


    But it is not getting binded niether i am getting any error.
    Please help.....
  2. rooma
    rooma avatar
    5 posts
    Member since:
    Aug 2011

    Posted 11 Oct 2011 Link to this post

    Anyone please help................
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 12 Oct 2011 Link to this post

    Hi Rooma,

    Unfortunately, there is a problem with title content databinding. Please, find attached a small example with a suggestion for a workaround.

    Regards,
    Ves
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Nicholas
    Nicholas avatar
    13 posts
    Member since:
    Oct 2012

    Posted 01 May 2012 Link to this post

    Hi rooma,

    I just spent way, way too long trying to sort this out.  I am incredulous that a WPF product has an issue with binding to the view model and it remains  unfixed.  Here is what I did to get around the problem after hours and hours of trying figure out what was wrong in my xaml.  It really never occurred to me that such basic functionality could be not  working. 

    I subscribed to the DataBound event to wire up my ChartTitle:

    <telerik:RadChart x:Name="scatterChart" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataBound="scatterChart_DataBound">

    I gave a name to my ChartTitle

    <telerik:ChartDefaultView.ChartTitle>

        <telerik:ChartTitle Content=""

                            x:Name="title"

                            HorizontalAlignment="Center"

                            Background="White"

                            Foreground="Black"

                             Visibility="Visible">

        </telerik:ChartTitle>

    </telerik:ChartDefaultView.ChartTitle>


    And I added the event handler in my code behind


    private void scatterChart_DataBound(object sender, Telerik.Windows.Controls.Charting.
    ChartDataBoundEventArgs e)

    {

    this.title.Content = ((ScatterChartViewModel)this.DataContext).ChartTitle;

    }


    I have a hard time grasping how this could not be corrected ASAP...  it is just such basic functionality.  This is a WPF product with a main GUI element that is not bindable to the view model in the xaml.  Outrageous!  It is not right!

    Hope this helps.

    Regards

  6. Enrique Albert
    Enrique Albert avatar
    4 posts
    Member since:
    May 2010

    Posted 27 Jun 2012 Link to this post

    Hi,

    I agree, we are assessing the Telerik WPF chart controls for a new commercial application and this sort of issue is a problem when considering the suite.

    Can you indicate if a defect has been logged against this issue and if there is a fix available?

    Thanks

    EDIT (Work around using dependency property that provides dynamic binding -- which above two solutions do not provide)

    I created a new class inheriting from RadChart:

     

        class NavitasRadChart
            :
    RadChart
        {
            
    public static readonly DependencyProperty ChartTitleProperty =
                
    DependencyProperty.Register(
                    
    "ChartTitle",
                    
    typeof(string),
                    
    typeof(NavitasRadChart),
                    
    new PropertyMetadata(string.Empty, OnChartTitleChanged));
     
            
    private static void OnChartTitleChanged(DependencyObject dependencyObject,
                
    DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
            {
                
    var chart = dependencyObject as NavitasRadChart;
                
    if (chart == nullreturn;
                chart.Refresh();
            }
     
            
    public string ChartTitle
            {
                
    get { return (string) GetValue(ChartTitleProperty); }
                
    set { SetValue(ChartTitleProperty, value); }
            }
     
            
    private void Refresh()
            {
                DefaultView.ChartTitle.Content = ChartTitle;
            }
        }

     

    So it contains a new 'ChartTitle' dependency property; when the property is changed it executes the new Refresh method that looks after the title content.

     

    The XAML in the view can use a binding expression, so if the model changes the title also changes:

     

                    <core:NavitasRadChart x:Name="radChart"                                  
                                     
     ...
                                     
     ChartTitle="{Binding Path=ChartTitleCaption}"
                                     
     >
                        ...
                    </core:NavitasRadChart>

     

    The 'core' namespace refers to the location of the new class, in my case:

    xmlns:core="clr-namespace:Navitas.Client.Core"

     

  7. Nicholas
    Nicholas avatar
    13 posts
    Member since:
    Oct 2012

    Posted 27 Jun 2012 Link to this post

    I do not know if "defect has been logged against this issue and if there is a fix available".

    It is also surprising that  binding does not seem to be possible custom lines or marked zones. I was further surprised there seems to be no way to bind a collection of ranges.  It seems reasonable to expect more than one range.
  8. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 02 Jul 2012 Link to this post

    Hello,

    The issues you are observing are caused by the difference between objects used for configuration and visual objects that are added to the visual tree at run time. We have identified this problem and we are taking actions to prevent such problems in our new charting solution - the RadChartView. In the chart view we are using only visual objects that work well with bindings.

    Please excuse us for the caused inconvenience!

    All the best,
    Yavor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  9. Nicholas
    Nicholas avatar
    13 posts
    Member since:
    Oct 2012

    Posted 03 Jul 2012 Link to this post

    Thanks for the follow up.  I tried out the RadChartView when it was Beta and I had to many issues, perhaps many from my own lack if experience even with the basics of .NET and WPF.  I had sort of forgotten about RadChartView but I think I will try it out again in hope of leveraging the more robust binding.  The charting requirements here are very complex and I am pushing the limits of RadChart. 

    Regards
  10. Nicholas
    Nicholas avatar
    13 posts
    Member since:
    Oct 2012

    Posted 03 Jul 2012 Link to this post

    Checked out RadChartView at seems it does not yet support all the feature required here (range series, custom lines, marked zones) and I can see no information on how to combine charts of different types.  Regardless, thanks for the follow up!
  11. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 06 Jul 2012 Link to this post

    Hi Nicholas,

    Custom lines and marked zones are currently under development and will be available with the Q3 release. Range series are also planned for the upcoming releases.

    You can check this demo here that demonstrates how you can combine series. You can also combine series of different types using the same technique.

    All the best,
    Yavor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
UI for WPF is Visual Studio 2017 Ready