Jump to content
Software FX Community

Databinding with a series


jonahsimpson
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 3 months later...

 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?

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...