WPF uses Dev and WinForm a lot of different, relatively speaking, WPF is simpler and more cool, I only do a little bit of basic functionality, without careful study, here is only the basis for WPF Dev Chartcontrol drawing Xydiagram.
Xydiagramcontrol.xaml page
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="Http://schemas.microsoft.com/winfx/2006/xaml"XMLNS:MC="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"XMLNS:DXC="Http://schemas.devexpress.com/winfx/2008/xaml/charts"XMLNS:DXMVVM="HTTP://SCHEMAS.DEVEXPRESS.COM/WINFX/2008/XAML/MVVM"x:class="Wpfcontrol.xydiagramcontrol"mc:ignorable="D"> <Grid> <dxc:chartcontrol horizontalalignment=" Left"margin="0,0,0,0"Verticalalignment="Top"> <dxc:xydiagram2d labelsresolveoverlappingminindent="2"X:name="diagram1"enableaxisxnavigation="True"> <dxc:XYDiagram2D.DefaultPane> <dxc:pane name="pane"/> </dxc:XYDiagram2D.DefaultPane> <dxc:XYDiagram2D.AxisY> <dxc:axisy2d gridlinesminorvisible="False"> </dxc:AxisY2D> </dxc:XYDiagram2D.AxisY> <dxc:xydiagra M2d.secondaryaxesy> </dxc:XYDiagram2D.SecondaryAxesY> <dxc:XYDiagram2D.AxisX> <dxc:axisx2d gridlinesvisible="False"/> </dxc:XYDiagram2D.AxisX> <dxc:lineseries2d markervisible="True"labelsvisibility="True"Argumentdatamember="Key"Valuedatamember="Value"X:name="series1"> <dxc:LineSeries2D.LineStyle> <dxc:linestyle thickness="1"/> </dxc:LineSeries2D.LineStyle> </dxc:LineSeries2D> </DXC: xydiagram2d> <dxc:ChartControl.Legend> <dxc:legend horizontalposition=" Right"/> </dxc:ChartControl.Legend> <dxc:ChartControl.ToolTipController> < ;d Xc:charttooltipcontroller autopopdelay="0"initialdelay="0"/> </dxc:ChartControl.ToolTipController> </dxc:ChartControl> </grid></usercon Trol>
XYDiagramControl.cs page
usingSystem.Collections.Generic;usingSystem.Windows.Controls;usingDevExpress.Xpf.Charts;usingDugufeixue.common;namespacewpfcontrol{/// <summary> ///the interactive logic of Usercontrol2.xaml/// </summary> Public Partial classXydiagramcontrol:usercontrol {DoubleMaxValue =0; Private CharDivider ='_'; PublicXydiagramcontrol (list<dataentity> decs,BOOLIsline,BOOLIsshowlabel,BOOLIssamey) {InitializeComponent (); intindex =0; foreach(Dataentity deinchdecs) {Series Series=NULL; if(!Issamey) { //set the second coordinate of the y-axisSecondaryaxisy2d Secondaryaxisy =Newsecondaryaxisy2d (); Diagram1. Secondaryaxesy.add (Secondaryaxisy); //set the title of the second coordinateAxisTitle title =NewAxisTitle (); Title. Content=de. Ytitle; Secondaryaxisy.title=title; if(isline) {//Create a new line chartSeries =Newlineseries2d (); //to set a series to associate with a second axisXydiagram2d.setseriesaxisy ((lineseries2d) series, secondaryaxisy); } Else { //Create a new bar chartSeries =Newbarsidebysideseries2d (); //set the label of a bar chartSerieslabel label =NewSerieslabel (); Label. Indent= -; Series. Label=label; if(Isshowlabel) {barsidebysideseries2d.setlabelposition (series. Label, Bar2dlabelposition.outside); } xydiagram2d.setseriesaxisy ((barsidebysideseries2d) series, secondaryaxisy); } } Else { if(isline) {series=Newlineseries2d (); } Else{Series=Newbarsidebysideseries2d (); Serieslabel label=NewSerieslabel (); Label. Indent= -; Series. Label=label; if(Isshowlabel) {barsidebysideseries2d.setlabelposition (series. Label, Bar2dlabelposition.outside); }}} series. Name="Series"+index; Series. DisplayName=de. Displayname; //set up a data source for a seriesSeries. DataSource =de. Dic; Series. Labelsvisibility=Isshowlabel; Series. Argumentdatamember="Key"; Series. Valuedatamember="Value"; //Add a series to the Xydiagramdiagram1. Series.add (series); Index++; } } }}
WPF DevExpress Chartcontrol Use of Xydiagram