命名空间中不存在C# WPF OxyPlot错误图

8hhllhi2  于 11个月前  发布在  C#
关注(0)|答案(3)|浏览(132)

嗨,我在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));
    }
}
}


也许有人有更好的解决办法。我只需要显示几个图表,其中包含来自传感器的大量数据,而不是真实的的。

piah890a

piah890a1#

我在NuGet的OxyPlot库从1.x版迁移到2.1版时也遇到了同样的问题。所以我发现,在版本2.1中,Plot类被移动到another library,请参阅their github page的发布历史。这对我很有效:
xmlns:oxy="http://oxyplot.org/wpf"
xmlns:oxycontrols="http://oxyplot.org/wpf/contrib"
<oxycontrols:Plot .../>

t1rydlwq

t1rydlwq2#

<Window x:Class="Universal_trc_csvParser.Window1"
        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:Universal_trc_csvParser"
        xmlns:oxy="http://oxyplot.org/wpf"
        mc:Ignorable="d"
        Title="Window1" Height="450" Width="800">

    <Window.DataContext>
        <local:MainViewModel/>
    </Window.DataContext>

    <Grid>
        <oxy:PlotView Model="{Binding MyModel}"/>
    </Grid>
</Window>

个字符
这对我很有效。

yyhrrdl8

yyhrrdl83#

我也有同样的问题。所以我所做的就是将我的“OxyPlot.Wpf”降级到1.0.0版本。你说的例子工作得很好,没有错误“名称plot不存在于名称空间中”。

<oxy:Plot x:Name="Plot1" Title="A Graph" Model="{Binding PlotModel}" Margin="10" Grid.Row="1">
    </oxy:Plot>

字符串

相关问题