Binding SeriesDefinition properties. RadChart is not updated

7 posts, 1 answers
  1. Peter
    Peter avatar
    2 posts
    Member since:
    Mar 2011

    Posted 01 Apr 2011 Link to this post

    Hi,

    I am trying to implement a binding for some properties of SeriesDefinition for RadChart in XAML. Here is a part of my XAML:

    <telerik:RadChart.SeriesMappings>
        <telerik:SeriesMapping LegendLabel="Rates" CollectionIndex="1">
            <telerik:SeriesMapping.SeriesDefinition>
                <telerik:LineSeriesDefinition AxisName="Rate" ItemLabelFormat="0.00 \%">
                    <telerik:LineSeriesDefinition.Visibility>
                        <Binding Path="ChartRateSeriesVisible" Source="{StaticResource ViewModel}" Converter="{StaticResource BooleanToSeriesVisibilityConverter}" />
                    </telerik:LineSeriesDefinition.Visibility>
                </telerik:LineSeriesDefinition>
            </telerik:SeriesMapping.SeriesDefinition>
        </telerik:SeriesMapping>
    </telerik:RadChart.SeriesMappings>

    This binding works fine, it gets the value from my ViewModel, so series are either visible on invisible.

    The issue is the following:
    I have a CheckBox on my View (UserControl defined in XAML) which is also binded to the same property of ViewModel (ChartRateSeriesVisible  property). And I want to control the visibility of a series by clicking on the checkbox. CheckBox's binding is defined property. I can see in the trace that checking/unchecking the checkbox updates the value of ChartRateSeriesVisible property.

    But chart is not updated automatically. Only then I reload the chart completely (by updating its ItemsSource for instance), my LineSeries is hidden or visible depending on the value of ChartRateSeriesVisible.

    What am I doing wrong or what am I missing?
    In the telerik's sample application 'Simple Filtering' almost the same approach is used! Series Visiblity property is also binded to the ViewModel's property, etc.

    I am using WPF 3.5 and the version of telerik assemblies is 2010.2.924.35.

    Thanks in advance.
  2. Peter
    Peter avatar
    2 posts
    Member since:
    Mar 2011

    Posted 01 Apr 2011 Link to this post

    One more thing. If I write the following event handler for checkbox in code-behind, my chart is updated right away.
    But I am trying to archive this 'filter' of series in XAML and ViewModel.

    (this.outputChart.DefaultView.ChartArea.DataSeries[1].Definition as LineSeriesDefinition).Visibility = checkBox.IsChecked.Value ? SeriesVisibility.Visible : SeriesVisibility.Collapsed;
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 06 Apr 2011 Link to this post

    Hello Peter,

    Indeed it seems there was a problem in this scenario with the version of RadChart you are using. Our developers have already addressed the issue and the use case works as expected in our local tests with the latest version of the control (see the attached sample application).

    Note that the DataContext is properly propagated to the SeriesDefinition now, so you do not need to explicitly set the binding source any more.

    Hope this helps.


    Regards,
    Giuseppe
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  5. Nidhi
    Nidhi avatar
    19 posts
    Member since:
    Jun 2011

    Posted 07 Jul 2011 Link to this post

    Hi Team,

    I have usercontrol contains chart. Iam using MVVM. I have binded Series Definition property of chart with ViewModel property.
    I added this control to Listbox items collection and its working first time. But second time, Chart is showing "No Series Defined". But view model property has value.

    The step iam taking to add usercontrol in List collection is..

    ----- Working First Time----Series Definition bind-- and showing chart
    UserControl_View cntrl=new UserControl_View();
    cntrl.DataContext=ViewModel(sigleton);
    List.items.Add(cntrl)

    Second time-- I remove from listbox items collection and add cntrl  again--but Series Definition is not binded
    UserControl_View cntrl=new UserControl_View();
    cntrl.DataContext=ViewModel(sigleton);
    List.items.Add(cntrl)

    If I create a another instance opf viewmodel , then its showing chart...
    UserControl_View cntrl=new UserControl_View();
    ViewModel viewmodel=new ViewModel();
    cntrl.DataContext=viewmodel
    List.items.Add(cntrl)

    But In don't want to create viewmodel instance every time.

    WE are loading single or multiple control in a listbox .

    Please see this issue...

    Thanks,
    Nidhi
  6. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 12 Jul 2011 Link to this post

    Hi Nidhi,

    Find attached a sample application that demonstrates how you can achieve the desired effect.

    Hope this helps.


    All the best,
    Giuseppe
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  7. Gregory
    Gregory avatar
    10 posts
    Member since:
    Aug 2010

    Posted 15 Jul 2011 Link to this post

    I am using version 2011.1.315.40 of the Chart controls and am  having a similar issue where, if I change any of the properties of the SeriesDefinition on a SeriesMapping instance, the change is applied to the chart the first time, but not on subsequent changes. I have tried a couple of workarounds, including calling the Rebind() method on the Chart as well as trying to upgrade to newer versions of the controls. I cannot use the newer versions because they don't seem to be backwards compatible with the 2011.1.315.40 release (for example, using the CollectionIndex with a SeriesMapping doesn't seem to work for me in the April release, and the Telerik.Windows.Themes.Office_Black.dll is no longer available in the July release; the Docking styles seem to have changed as well).

    Is there a workaround that I can apply on the 2011.1.315.40 release that will allow me to update the chart appearance any time that the SeriesDefinition properties are changed?
  8. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 21 Jul 2011 Link to this post

    Hello Gregory,

    Find attached a sample application that demonstrates how you can change appearance settings through bindings with version 2011.1.315.40.

    As for the CollectionIndex issue -- we have addressed the following issue in the July release: SeriesMapping.ItemsSource not respected when SeriesMapping.CollectionIndex is set. Also, generally the Office_Black theme is the default theme for all WPF controls and it is embedded in the control assembly.

    About the docking styles -- could you elaborate a bit on the problems you are experiencing so we can advise you properly how to proceed.


    Greetings,
    Giuseppe
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top
UI for WPF is Visual Studio 2017 Ready