如何重置缩放 oxyplot c# wpf
How to reset zoom oxyplot c# wpf
我有一个 oxyplot RectangleBarSeries 和一个按钮 "Reset"。当我按下按钮时,我希望重置缩放(与按下键盘上的 A 时缩放重置的方式相同)。
我试图通过在 MainPanel.xaml.cs:
中添加一个带有以下代码的事件处理程序来实现这一点
private void Reset_Click(object sender, RoutedEventArgs e)
{
histogram.PlotModel.Axes[0].Reset();
histogram.PlotModel.Axes[1].Reset();
}
但出现错误 "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"。
我应该写什么来重置绘图的缩放?
我的直方图的一部分 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);
}
尝试使用MyPlotViewName.ResetAllAxes();相反,那应该有效。
我有一个 oxyplot RectangleBarSeries 和一个按钮 "Reset"。当我按下按钮时,我希望重置缩放(与按下键盘上的 A 时缩放重置的方式相同)。
我试图通过在 MainPanel.xaml.cs:
中添加一个带有以下代码的事件处理程序来实现这一点private void Reset_Click(object sender, RoutedEventArgs e)
{
histogram.PlotModel.Axes[0].Reset();
histogram.PlotModel.Axes[1].Reset();
}
但出现错误 "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"。
我应该写什么来重置绘图的缩放?
我的直方图的一部分 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);
}
尝试使用MyPlotViewName.ResetAllAxes();相反,那应该有效。