<Grid x:Name="myGrid" Loaded="Grid_Loaded" DataContext="{Binding PartOneData}"> <dxc:ChartControl Name="chartControl1" DataSource="{Binding ComplainAnalysisList}"> <dxc:ChartControl.Diagram> <dxc:XYDiagram2D SeriesDataMember="Key"> <dxc:XYDiagram2D.SeriesTemplate> <dxc:BarSideBySideSeries2D ArgumentDataMember="Key" ValueDataMember="Value" /> </dxc:XYDiagram2D.SeriesTemplate> <dxc:XYDiagram2D.AxisX> <dxc:AxisX2D> </dxc:AxisX2D> </dxc:XYDiagram2D.AxisX> </dxc:XYDiagram2D> </dxc:ChartControl.Diagram> <!--<dxc:ChartControl.Legend> <dxc:Legend /> </dxc:ChartControl.Legend>--> </dxc:ChartControl> </Grid>
You only need to bind a data source to the outermost grid or other space, bind datasource to the chart control, and specify the seriesdatamember, argumentdatamemeber, and valuedatamember of the bar chart in the chart control.
At the beginning, I only found the method of binding through the C # code, because the print template is used in the project, and the template does not have the C # code background. All the tangle issues have been entangled for a long time, after the research, we found that it was so simple. Next we need to study the function of mixing multiple columns and curves in the next chart. We also need to rely on the two Y axes to continue to refuel ......
Bind the data source on the WPF interface instead of using the C # code.