我有一个氧气图表。调用方法“OnClearAll”时,我希望这些图表消失/删除。
我想要这样的事情:
private void OnClearAll()
{
HistoView.Clear();
}
但是不存在明确的。
我应该写什么来删除我的图表?
My MainPanel 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);
}
答案 0 :(得分:1)
尝试将Model
或DataContext
属性设置为null
:
private void OnClearAll()
{
HistoView.DataContext = null;
}