2

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

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 的绑定后,它仍然可以工作。为什么?如何禁用右键平移并启用左键?

4

1 回答 1

2

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

TestView.ActualController.UnbindAll();

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

于 2015-04-13T09:48:53.983 回答