您好,我在配置WPF中的oxyplot时遇到了问题。我找到了一些解决方案,但都没有奏效。我发现这是最好的http://blog.bartdemeyer.be/2013/03/creating-graphs-in-wpf-using-oxyplot/,但仍然有问题,在XAML文件中出现以下错误:
名称空间codeplex中不存在名为plot的内容。
MainWindow.xaml文件:
<Window x:Class="OxyPlotDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:OxyPlotDemo"
xmlns:oxy="http://oxyplot.codeplex.com"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<oxy:Plot x:Name="Plot1" Title="A Graph" Model="{Binding PlotModel}" Margin="10" Grid.Row="1">
</oxy:Plot>
</Grid>
MainWindow.xaml.cs
using System.Windows;
namespace OxyPlotDemo
{
public partial class MainWindow : Window
{
private ViewModels.MainWindowModel viewModel;
public MainWindow()
{
viewModel = new ViewModels.MainWindowModel();
DataContext = viewModel;
InitializeComponent();
}
}
}
MainWindowModel.cs
using System.ComponentModel;
using OxyPlot;
namespace OxyPlotDemo.ViewModels
{
public class MainWindowModel : INotifyPropertyChanged
{
private PlotModel plotModel;
public PlotModel PlotModel
{
get { return plotModel; }
set { plotModel = value; OnPropertyChanged("PlotModel"); }
}
public MainWindowModel()
{
PlotModel = new PlotModel();
}
public event PropertyChangedEventHandler PropertyChanged;
//[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
也许有更好的解决方案。我只需要显示一些包含传感器大量数据的图表,不需要实时展示。
xmlns:oxy="http://oxyplot.org/wpf"
。 - Jose<oxy:PlotView>
代替<oxy:Plot>
- Jose