Binding problems with ChartSeriesProvider

2 posts, 0 answers
  1. Ingólfur
    Ingólfur avatar
    11 posts
    Member since:
    Jun 2012

    Posted 29 Apr 2013 Link to this post

    I'm having problems binding my MVVM ViewModel to the ChartSeriesProvider. It's like it's not a part of the Visual Tree.

    <telerik:RadCartesianChart>
                 
                <telerik:RadCartesianChart.HorizontalAxis>
                    <telerik:CategoricalAxis/>
                </telerik:RadCartesianChart.HorizontalAxis>
                <telerik:RadCartesianChart.VerticalAxis>
                    <telerik:LinearAxis/>
                </telerik:RadCartesianChart.VerticalAxis>
                <telerik:RadCartesianChart.SeriesProvider>
                     
                    <telerik:ChartSeriesProvider Source="{Binding Path=CollectionView}">
                        <telerik:ChartSeriesProvider.SeriesDescriptors>
     
                            <telerik:CategoricalSeriesDescriptor ItemsSourcePath="Items"
                                                                 ValuePath="Value"
                                                                 CategoryPath="Month">
                                <telerik:CategoricalSeriesDescriptor.Style>
                                    <Style  TargetType="telerik:LineSeries">
                                    </Style>
                                </telerik:CategoricalSeriesDescriptor.Style>
                            </telerik:CategoricalSeriesDescriptor>
                        </telerik:ChartSeriesProvider.SeriesDescriptors>
                         
                    </telerik:ChartSeriesProvider>
                     
                </telerik:RadCartesianChart.SeriesProvider>
            </telerik:RadCartesianChart>

    and inside the ViewModel that is bound to this view (is its DataContext)

    private ICollectionView _collectionView;
    public ICollectionView CollectionView
    {
        get
        {
            if (this._collectionView == null)
            {
                this._collectionView = CollectionViewSource.GetDefaultView(this.Items);
                    using (this._collectionView.DeferRefresh())
                    {
                        this._collectionView.SortDescriptions.Clear();
                        this._collectionView.SortDescriptions.Add(new SortDescription("Order", ListSortDirection.Ascending));
                    }
            }
            return this._collectionView;
        }
    }

    Everything else in the View binds ok but I always get no series and according to Snoop

    RadChartView Cannot find governing FrameworkElement or FrameworkContentElement for target element
  2. Ingólfur
    Ingólfur avatar
    11 posts
    Member since:
    Jun 2012

    Posted 30 Apr 2013 Link to this post

    Ok I am using Caliburn.Micro to wire up the DataContexts and I guess the problem was there somewhere instead of in Telerik code. Sorry about that.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top