简体   繁体   English

如何重设缩放oxyplot C#WPF

[英]How to reset zoom oxyplot c# wpf

I have an oxyplot RectangleBarSeries and a button "Reset". 我有一个oxyplot RectangleBarSeries和一个按钮“ Reset”。 When I press the button I want the zoom to reset (in the same way the zoom resets when A is pressed on the keyboard). 当我按下按钮时,我想重置变焦(以相同的方式,当在键盘上按A时,变焦会重置)。

I have tried to achieve this by adding an eventhandler with the following code in my MainPanel.xaml.cs: 我试图通过在MainPanel.xaml.cs中添加带有以下代码的事件处理程序来实现此目的:

private void Reset_Click(object sender, RoutedEventArgs e)
    {
       histogram.PlotModel.Axes[0].Reset();
       histogram.PlotModel.Axes[1].Reset(); 
    } 

but get the error "myNameSpace.Histogram does not contain a definition for PlotModel and no extension method "PlotModel" accepting a first argument of type myNameSpace.Histogram could be found". 但出现错误“ myNameSpace.Histogram不包含PlotModel的定义,并且找不到扩展方法“ PlotModel”接受类型为myNameSpace.Histogram的第一个参数”。

What should I write instead to be able to reset the zoom on my plot? 我应该写些什么才能重置绘图的缩放比例?

Part of my Histogram class: 我的直方图课程的一部分:

namespace myNameSpace
{
    public class Histogram : INotifyPropertyChanged
    {
    public Collection<Item> Items { get; set; }
    private PlotModel histogramModel;
    public PlotModel HistogramModel
    {
        get { return histogramModel; }
        set { histogramModel = value; OnPropertyChanged("HistogramModel"); }
    }

    public class Item
    {
        public string Label { get; set; }
        public double Value { get; set; }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    //NotifyPropertyChangedInvocator
    protected virtual void OnPropertyChanged(string propertyName)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (handler != null)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    public Histogram(List<double> frequency, List<double> axis, string VariableName)
    {
        CreateRectangleBar(frequency, axis, VariableName);
    }

Try to use MyPlotViewName.ResetAllAxes(); 尝试使用MyPlotViewName.ResetAllAxes(); instead, that should work. 相反,那应该起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM