在 WPF 中创建 OxyPlot
Create an OxyPlot in WPF
我在 WPF 中使用 OxyPlot 时遇到了一些问题。我正在尝试创建一个应用程序并想使用 OxyPlot 创建图表。除了 plot/the 数据不会显示外,一切正常。我似乎无法弄清楚为什么。
这是我的一些 xaml 代码:
<UserControl x:Class="myNameSpace.MainPanel"
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:app="clr-namespace:myNameSpace"
xmlns:oxy="http://oxyplot.org/wpf"
mc:Ignorable="d"
d:DesignHeight="1200"
d:DesignWidth="1920">
<UserControl.DataContext>
<local:MainViewModel/>
</UserControl.DataContext>
....
<oxy:Plot Title="{Binding Title}" Margin="760,689,606,228" Width="504" Height="283">
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding Points}"/>
</oxy:Plot.Series>
</oxy:Plot>
我的 MainViewPanel class 看起来像这样:
public class MainViewModel
{
public MainViewModel()
{
this.Title = "Example 2";
this.Points = new List<DataPoint>
{
new DataPoint(0, 4),
new DataPoint(10, 13),
new DataPoint(20, 15),
new DataPoint(30, 16),
new DataPoint(40, 12),
new DataPoint(50, 12)
};
}
public string Title { get; private set; }
public IList<DataPoint> Points { get; private set; }
}
这是我 运行 我的代码
时图表的样子
删除边距,因为它们会遮挡您的图表形式。
<oxy:Plot Title="{Binding Title}" Width="504" Height="283">
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding Points}"/>
</oxy:Plot.Series>
</oxy:Plot>
我没有看到定义的本地命名空间前缀。如果 MainViewModel 在 AnnaEmilie 命名空间中,将 local:MainViewModel
更改为 app:MainViewModel
我在 WPF 中使用 OxyPlot 时遇到了一些问题。我正在尝试创建一个应用程序并想使用 OxyPlot 创建图表。除了 plot/the 数据不会显示外,一切正常。我似乎无法弄清楚为什么。
这是我的一些 xaml 代码:
<UserControl x:Class="myNameSpace.MainPanel"
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:app="clr-namespace:myNameSpace"
xmlns:oxy="http://oxyplot.org/wpf"
mc:Ignorable="d"
d:DesignHeight="1200"
d:DesignWidth="1920">
<UserControl.DataContext>
<local:MainViewModel/>
</UserControl.DataContext>
....
<oxy:Plot Title="{Binding Title}" Margin="760,689,606,228" Width="504" Height="283">
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding Points}"/>
</oxy:Plot.Series>
</oxy:Plot>
我的 MainViewPanel class 看起来像这样:
public class MainViewModel
{
public MainViewModel()
{
this.Title = "Example 2";
this.Points = new List<DataPoint>
{
new DataPoint(0, 4),
new DataPoint(10, 13),
new DataPoint(20, 15),
new DataPoint(30, 16),
new DataPoint(40, 12),
new DataPoint(50, 12)
};
}
public string Title { get; private set; }
public IList<DataPoint> Points { get; private set; }
}
这是我 运行 我的代码
时图表的样子删除边距,因为它们会遮挡您的图表形式。
<oxy:Plot Title="{Binding Title}" Width="504" Height="283">
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding Points}"/>
</oxy:Plot.Series>
</oxy:Plot>
我没有看到定义的本地命名空间前缀。如果 MainViewModel 在 AnnaEmilie 命名空间中,将 local:MainViewModel
更改为 app:MainViewModel