Emelie
Emelie

Reputation: 119

How to delete plot oxyplot C#

I have a oxyplot charts. When the method "OnClearAll" is called I want these charts to disappear/ be deleted.

I want something like this:

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

However clear does not exist.

What should I write instead to delete my chart?

My MainPanel xaml:

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

My histogram class:

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);
        }

Upvotes: 1

Views: 1698

Answers (1)

mm8
mm8

Reputation: 169220

Try to set the Model or DataContext property to null:

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

Upvotes: 2

Related Questions