How to refresh oxyplot plot when data changes

前端 未结 7 1344
予麋鹿
予麋鹿 2021-02-07 02:10

\"GUI

Oxyplot graphs 13 points which are derived from the 6 user input text boxes. The values in

7条回答
  •  难免孤独
    2021-02-07 03:00

    The cleanest way I've found to get "sort of" auto-update is reacting to CollectionChanged on the collection that is LineSeries' ItemsSource.

    In ViewModel:

    ObservableCollection Data { get; set; } 
        = new ObservableCollection();
    
    public PlotModel PlotModel
    {
        get { return _plot_model; }
        set
        {
            _plot_model = value;
            RaisePropertyChanged(() => PlotModel);
        }
    }
    PlotModel _plot_model;
    
    // Inside constructor:
    Data.CollectionChanged += (a, b) => PlotModel.InvalidatePlot(true);
    

提交回复
热议问题