jonahsimpson Posted September 10, 2009 Report Share Posted September 10, 2009 Hi! I'm creating a little WPF control that will allow the user to add series to a chart at runtime. I'm trying to implement this control using MVVM and I can't seem to find a way to set up the bindings on the chart's SeriesAttributesCollection. It seems like this isn't really possible: <cfx:Chart Name="chart1" ItemsSource="{Binding Data}" Series="{Binding Series}"> Is there a recommended way of achieving this kind of functionality or am I missing something? Thanks! Quote Link to comment Share on other sites More sharing options...
JuanC Posted September 11, 2009 Report Share Posted September 11, 2009 The chart class does not support binding to the Series property. In order to make our control more useful in MVVM situations we created a separate class called ChartView in the same assembly. This class adds binding support to the Series property. Please note that many collections in WPF do not support bindings, e.g. Grid.ColumnDefinitions, it is possible that other collections in the ChartView class will not support bindings. We will add support for these depending on customer feedback. Regards, JuanC Quote Link to comment Share on other sites More sharing options...
poonwahj Posted December 18, 2009 Report Share Posted December 18, 2009 I'm trying to bind a set of data from an MVVM type project to a ChartView that is completely constructed in Xaml. Our architecture requires that we are able to change which values are bound to which two series, which values to use for the X axis, and which values are used for the Y axis. I have view models exposing strings for the selected values (Series1, Series2, X, Y) which are detected in code by the ChartView's ItemSource which is bound to the DataSet exposed by the ViewModel, like so: <cfx:ChartView x:Name="chart1" ItemsSource="{Binding Path=DataSource}" Gallery="Bar"> <cfx:ChartView.Series> <cfx:SeriesAttributes BindingPath="{Binding Path=Series1Column}" /> <cfx:SeriesAttributes BindingPath="{Binding Path=Series2Column}" /> </cfx:ChartView.Series> <cfx:ChartView.AxisX> <cfx:Axis AutoScale="True" DataPath="{Binding Path=XAxis}" /> </cfx:ChartView.AxisX> <cfx:ChartView.AxisY> <cfx:Axis AutoScale="True" DataPath="{Binding Path=YAxis}"/> </cfx:ChartView.AxisY> </cfx:ChartView> This obviously doesn't work, but maybe you can see what I'm trying to do. Is this possible in Xaml? Am I on the right track? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.