4

Hi I have a problem configuring oxyplot in WPF. I have found a few solutions but nothing works. I have found out that this is the best http://blog.bartdemeyer.be/2013/03/creating-graphs-in-wpf-using-oxyplot/ but something still wrong and I get this error in XAML file:

the name plot does not exist in the namespace codeplex

MainWindow.xaml FILE:

<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));
    }
}
}

Maybe someone has better solution. I just need to display a few charts, that contains a lot of data from sensors, not in real time.

8
  • 2
    Try using xmlns:oxy="http://oxyplot.org/wpf" Commented Dec 23, 2016 at 7:02
  • @Kirenenko i tried it and when i do this error appear also in XAML but it's write : The member "Mode" is not recognized or is not accesible Commented Dec 23, 2016 at 10:32
  • Maybe you have writen "Mode" instead of "Model" in some part of your code? Commented Dec 23, 2016 at 10:35
  • @Kirenenko sorry i make mistake in writing, error contains word Model not Mode Commented Dec 23, 2016 at 12:02
  • 1
    Use <oxy:PlotView instead of <oxy:Plot Commented Dec 23, 2016 at 12:04

3 Answers 3

7

I've had a same issue with OxyPlot lib from NuGet, when migrating from lib version 1.x to 2.1. SO i found, that in version 2.1 Plot class is moved to another library, see releases history at their github page. That worked for me:

  1. Download additional library OxyPlot.Contrib.Wpf to your project via NuGet.
  2. Add these declarations to XAML:
    • xmlns:oxy="http://oxyplot.org/wpf"

    • xmlns:oxycontrols="http://oxyplot.org/wpf/contrib"

    • <oxycontrols:Plot .../>

Sign up to request clarification or add additional context in comments.

Comments

3
<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>

public class MainViewModel
    {
    public MainViewModel()
        {
        this.MyModel = new PlotModel { Title = "Example 1" };
        this.MyModel.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)"));
        }

    public PlotModel MyModel { get; private set; }
    }

This worked for me.

1 Comment

This works for brand new oxyplot 2.1.0, all other documents are outdated.
1

I had the same issue. So what i did was downgrade my "OxyPlot.Wpf" to version 1.0.0. and the example you speak of works fine, without the error "the name plot does not exist in the namespace".

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.