Hi,@Tan, Thuan Seah. Welcome Microsoft Q&A.
Microsoft does not have an official control for drawing scatter plots in WPF. The System.Windows.Controls.DataVisualization.Toolkit
library you mentioned package only contains assemblies for the .NET Framework 4.0 Client Profile. Therefore, it is not compatible with any version of .NET Core.
Since this package is not an official Microsoft package and there are no updates for .NET Core
If you prefer not to use third-party libraries, you could use the System.Windows.Forms.DataVisualization
library as Castorix31 said, which is part of the .NET Framework and includes a Chart control that can be used to draw scatter plots.
First, add references to the following assemblies to your WPF project.
- System.Windows.Forms.DataVisualization
- System.Windows.Forms.DataVisualization.Design
- System.Windows.Forms
- WindowsFormsIntegration
MainWindow.xaml:
<Grid x:Name="grid">
</Grid>
MainWindow.xaml.cs:
using System.Windows;
using System.Windows.Forms.DataVisualization.Charting;
namespace WpfApp3
{
public partial class MainWindow : Window
{
Chart chart1 = new Chart();
public MainWindow()
{
InitializeComponent();
System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
draw();
chart1.Titles.Add(" Chart");
host.Child = chart1;
grid.Children.Add(host);
}
public Chart draw()
{
ChartArea ChartArea1 = new ChartArea();
this.chart1.ChartAreas.Add("ChartArea1");
this.chart1.Series.Add("series");
this.chart1.Series[0].Points.AddXY(1, 5);
this.chart1.Series[0].Points.AddXY(2, 4);
this.chart1.Series[0].Points.AddXY(3, 3);
this.chart1.Series[0].Points.AddXY(4, 2);
this.chart1.Series[0].Points.AddXY(5, 1);
return chart1;
}
}
}
The result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.