Trouble getting plot to refresh

Oystein Bjorke 6 years ago 0
This discussion was imported from CodePlex

willmoore88 wrote at 2013-07-11 10:43:

My xaml defining my plot.
    <Grid Style="{StaticResource ContentRoot}">
        <oxy:Plot x:Name="CloudLayerPlot" Model="{Binding CloudLayerPlotModel}" Width="600" Margin="0,0,0,0" />
Some of the code behind this XAML page.
    public PlotModel CloudLayerPlotModel { get; set; }

    public cloudDetectionGraph()
        DataContext = this;
I then call this code:
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

            CloudLayerPlotModel = plotModel1;
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 ; }
                    cloudPlotModel = value;

       protected void OnPropertyChanged(string name)
                 PropertyChangedEventHandler handler = PropertyChanged;
                 if (handler != null)
                     handler(this, new PropertyChangedEventArgs(name));
I hope this will resolve your problem

willmoore88 wrote at 2013-07-11 14:45:

Thank you so much!