Does XamDataChart Stackedcolumnseries work with MVVM? I have collection that regularly changes in my view model . I am unable to get a collection exposed as a public property in the view model to bind to the view. No columns in the StackColumnSeries are populated. I only can see a few grid lines.
I have the same question. In the example below, if I were to set my viewmodel in code behind and had a specific property I was referencing on the view model (called EnergyProdData), which is an IEnumerable, how could i set the stacked column fragments so that it would reflect the data? It seems to work perfectly for the regular column series but if we switch it to StackedColumnSeries, it shows the axes but never displays the data. Here's my xaml and code behind based off the help.infragistics.com example:
<ig:XamDataChart x:Name="DataChart">
<ig:XamDataChart.Axes>
<ig:NumericYAxis x:Name="YAxis" MinimumValue="0" Label
="{}{} %" />
<ig:CategoryXAxis x:Name="XAxis" ItemsSource="{Binding EnergyProdData}" Label
="{}{Country}" />
</ig:XamDataChart.Axes
>
<ig:XamDataChart.Series
<ig:StackedColumnSeries XAxis="{Binding ElementName=XAxis}"
YAxis="{Binding ElementName=YAxis}"
ItemsSource="{Binding EnergyProdData
}"
<ig:StackedColumnSeries.Series
<ig:StackedFragmentSeries ValueMemberPath="Coal" Title
="Coal"/>
<ig:StackedFragmentSeries ValueMemberPath="Hydro" Title
="Hydro" />
<ig:StackedFragmentSeries ValueMemberPath="Nuclear" Title
="Nuclear" />
<ig:StackedFragmentSeries ValueMemberPath="Gas" Title
="Gas" />
<ig:StackedFragmentSeries ValueMemberPath="Oil" Title
="Oil" />
</ig:StackedColumnSeries.Series
</ig:StackedColumnSeries
</ig:XamDataChart.Series
</ig:XamDataChart
Code behind:
public partial class Page2 : Page { public Page2() { InitializeComponent();
Model m = new Model();
this.DataContext = m; }
// Executes when the user navigates to this page. protected override void OnNavigatedTo(NavigationEventArgs e) { }
}
public class Model { private List<EnergyProduction> _energyProdData = new List<EnergyProduction>();
public Model() { _energyProdData = new List<EnergyProduction>();
_energyProdData.Add(new EnergyProduction { Region = "America", Country = "Canada", Coal = 400, Oil = 100, Gas = 175, Nuclear = 225, Hydro = 350 }); _energyProdData.Add(new EnergyProduction { Region = "Asia", Country = "China", Coal = 925, Oil = 200, Gas = 350, Nuclear = 400, Hydro = 625 }); _energyProdData.Add(new EnergyProduction { Region = "Europe", Country = "Russia", Coal = 550, Oil = 200, Gas = 250, Nuclear = 475, Hydro = 425 }); _energyProdData.Add(new EnergyProduction { Region = "Asia", Country = "Australia", Coal = 450, Oil = 100, Gas = 150, Nuclear = 175, Hydro = 350 }); _energyProdData.Add(new EnergyProduction { Region = "America", Country = "United States", Coal = 800, Oil = 250, Gas = 475, Nuclear = 575, Hydro = 750 }); _energyProdData.Add(new EnergyProduction { Region = "Europe", Country = "France", Coal = 375, Oil = 150, Gas = 350, Nuclear = 275, Hydro = 325 }); }
//IEnumerable binding source public List<EnergyProduction> EnergyProdData { get { return _energyProdData; } } }
TIA
<ig:XamDataChart x:Name
="DataChart">
<ig:XamDataChart.Axes
Hmm.. your code as presented works fine for me. What version of the product are you currently using?
-Graham