OxyPlot 绘图控制器

OxyPlot PlotController

我正在尝试禁用右键自动平移。

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

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

解绑所有 PlotCommand 后它仍然 working.Why?如何在右键上禁用平移并在左键上启用?

在您的 MainWindow 初始化代码中试试这个:

TestView.ActualController.UnbindAll();

TestView 是您在 XAML 中定义的 PlotView 的名称。