我已经做了一个示例项目,试图修复这个错误,但没有运气。我做了一个简单的WPF应用程序,里面有一个Plot和一个Button。单击该按钮时,它会将X轴的最小值设置为100,将最大值设置为500。当我打开应用程序时,它可以工作,但一旦我平移/缩放图表,它就停止工作。
Minimum和ActualMinimum也是如此。下面是我的PlotModel代码和MainWindow代码。如果我的格式有问题,我深表歉意,我会尽快修复它。
public class OxyPlotModel : INotifyPropertyChanged
{
private OxyPlot.PlotModel plotModel;
public OxyPlot.PlotModel PlotModel
{
get
{
return plotModel;
}
set
{
plotModel = value;
OnPropertyChanged("PlotModel");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
}
public MainWindow()
{
InitializeComponent();
oxyPlotModel = new OxyPlotModel();
oxyPlotModel.PlotModel = plotModel;
plotView1.DataContext = oxyPlotModel;
plotModel.Axes.Clear();
var yAxis = new OxyPlot.Axes.LinearAxis();
var xAxis = new OxyPlot.Axes.LinearAxis();
xAxis.Position = OxyPlot.Axes.AxisPosition.Bottom;
plotModel.Axes.Add(yAxis);
plotModel.Axes.Add(xAxis);
plotModel.Axes[1].Minimum = 0;
plotModel.Axes[1].Maximum = 700;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
plotModel.Axes[1].Minimum = 100;
plotModel.Axes[1].Maximum = 500;
Debug.Print(plotModel.Axes[1].MaximumPadding.ToString());
plotModel.InvalidatePlot(true);
}发布于 2019-08-02 22:22:06
我通过使用Axis.Zoom而不是Maximum和Minimum修复了它。
https://stackoverflow.com/questions/57327202
复制相似问题