Trouble getting plot to refresh
This discussion was imported from CodePlex
willmoore88 wrote at 2013-07-11 10:43:
My xaml defining my plot.
When I call this function the first time, the plot is drawn correctly, subsequent calls don't though.
<Grid Style="{StaticResource ContentRoot}">
<oxy:Plot x:Name="CloudLayerPlot" Model="{Binding CloudLayerPlotModel}" Width="600" Margin="0,0,0,0" />
</Grid>
Some of the code behind this XAML page. public PlotModel CloudLayerPlotModel { get; set; }
public cloudDetectionGraph()
{
InitializeComponent();
DataContext = this;
}
I then call this code: makeCloudLayerPlotModel();
private void makeCloudLayerPlotModel()
{
var end = new DateTime();
end = DateTime.Now;
var start = new DateTime();
start = end.AddDays(-1);
// Create data collection
var data = new Collection<DateValue>();
var date = start;
// Other code here - removed as it's quite long
plotModel1.Series.Add(lineSeries1);
plotModel1.Series.Add(lineSeries2);
plotModel1.Series.Add(lineSeries3);
plotModel1.Series.Add(lineSeries4);
CloudLayerPlotModel = plotModel1;
CloudLayerPlotModel.RefreshPlot(true);
}
I've tried using RefreshPlot() in different places, ie. after when I call my function to make the plotmodel. I've also tried using invalidateplot() but no joy there either. Sure it's something i'm just overlooking!
When I call this function the first time, the plot is drawn correctly, subsequent calls don't though.
raphay wrote at 2013-07-11 14:06:
I think it is just a binding problem, you should implement INotifyPropertyChanged for your main class:
YourClass : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
PlotModel cloudLayerPlotModel;
public PlotModel CloudLayerPlotModel {
get{ return cloudPlotModel ; }
set
{
cloudPlotModel = value;
OnPropertyChanged("CloudLayerPlotModel");
}
}
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
}
I hope this will resolve your problemwillmoore88 wrote at 2013-07-11 14:45:
Thank you so much!
Customer support service by UserEcho