Xamarin AndroidでOxyplotグラフをリフレッシュする際に問題があります。 Model.InvalidatePlot(true)を使用していますが、まだ動作しません。Xamarin Android Oxyplotの更新がうまくいきません
私のViewModelには、PlotModelプロパティと、次のようなリフレッシュのためのメソッドがあります。 GroupSalesはGroupSaleの私のMvxObservableCollectionです。
public void RefreshTest()
{
GroupSales.Clear();
var groupSales = DemoData.GetGroupSaleList(_shop.Id);
groupSales.Add(new GroupSale()
{
Name = "Test",
Sum = 5555,
Color = Constants.DefaultColor
});
foreach (var item in groupSales)
{
GroupSales.Add(item);
}
Model = OxyPlotModelCreator.GetGroupSalesModel(GroupSales);
Model.InvalidatePlot(true);
}
private PlotModel _model;
public PlotModel Model
{
get { return _model; }
set
{
_model = value;
RaisePropertyChanged(() => Model);
}
}
呼び出しメソッドRefreshTest my MvxObservableCollectionが更新され、モデルはまだ見えますが、見た目は同じです。 Imがモバイルの向きを変更したときにのみ(その直後に、ポートレートとランドスケープの2つのビューを使用して、その初期化された)ビューを更新しますが、リフレッシュボタンをクリックしてからPlotModelをリフレッシュする必要があります。
私はすでにこのようなAndroidの断片及びInvalidete PlotViewとモデルでは、このメソッドを呼び出してみました:誰かが私を助けることができます....
Button button = _view.FindViewById<Button>(Resource.Id.refreshButton);
button.Click += delegate
{
ViewModel.RefreshTest();
if (plotView != null && ViewModel.Model != null)
{
plotView.InvalidatePlot(true);
plotView.Invalidate();
plotView.RefreshDrawableState();
plotView.Model.InvalidatePlot(true);
}
};
しかし、まだdoesntの仕事?
EDIT
私はこのようなフラグメントでモデルを初期化します。
var bindset = this.CreateBindingSet<GroupSalesFragment, GroupSalesViewModel>();
bindset.Bind(plotView).For(c => c.Model).To(vm => vm.Model);
bindset.Apply();
とその:
var plotView = _view.FindViewById<PlotView>(Resource.Id.groupSalesModel);
if (plotView != null && ViewModel.Model != null)
{
plotView.Model = ViewModel.Model;
}