【问题标题】:How to delete plot oxyplot C#如何删除绘图 oxyplot C#
【发布时间】:2017-07-11 11:20:56
【问题描述】:

我有一个 oxyplot 图表。当调用“OnClearAll”方法时,我希望这些图表消失/被删除。

我想要这样的东西:

private void OnClearAll()
{
    HistoView.Clear(); 
}

然而明确的并不存在。

我应该写什么来删除我的图表?

我的主面板 xaml:

<oxy:PlotView x:Name ="HistoView" Model="{Binding HistogramModel}" Margin="476,304,102,459"/>

我的直方图类:

namespace myNameSpace
{
    public class Histogram : INotifyPropertyChanged
    {
        //private Histogram DataContext;

        public Collection<Item> Items { get; set; }
        private PlotModel histogramModel;
        public PlotModel HistogramModel //{ get; set; }
        {
            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);
        }

【问题讨论】:

    标签: c# wpf oxyplot


    【解决方案1】:

    尝试将ModelDataContext 属性设置为null

    private void OnClearAll()
    {
        HistoView.DataContext = null; 
    }
    

    【讨论】:

      猜你喜欢
      • 2023-04-07
      • 2020-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-16
      • 1970-01-01
      相关资源
      最近更新 更多