Search code examples
c#wpfoxyplot

OxyPlot PlotController


I am trying to disable auto panning on right button.

using OxyPlot;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using OxyPlot.Wpf;
using PlotController.Properties;
namespace PlotController
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
/// 
public class Chart
{
    private OxyPlot.Series.LineSeries LS;
    public PlotModel PlotModel {get;set;}
    public Chart()
    {
        Random rnd = new Random();
        PlotModel = new PlotModel();

        LS = new OxyPlot.Series.LineSeries();
        for (int i=0;i<100;i++)
        {
            LS.Points.Add(new DataPoint(i, rnd.Next(1,10)));
        }
        PlotModel.Series.Add(LS);
    }
}
public partial class MainWindow : Window
{
    Chart TChart;
    public MainWindow()
    {
        TChart = new Chart();
        OxyPlot.PlotController MyControl = new OxyPlot.PlotController();
        MyControl.UnbindAll();
        TestView = new PlotView();
        TestView.Model = TChart.PlotModel;
        TestView.Controller=MyControl;
        DataContext = TChart;

        InitializeComponent();
    }
}
}

And xaml * *

<Window x:Class="PlotController.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:oxy="http://oxyplot.org/wpf"
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <oxy:PlotView Name="TestView"  Model="{Binding PlotModel}" DefaultTrackerTemplate="{x:Null}" ></oxy:PlotView>
</Grid>

After unbinding all PlotCommand it still working.Why? How possible to disable panning on right button and enable on left button?


Solution

  • Try this in your MainWindow initialization code:

    TestView.ActualController.UnbindAll();
    

    TestView is the name of your PlotView defined in XAML.