XAML button bound to ReactiveCommand does not get enabled when execution finishes

46 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Atle

ungelesen,
20.02.2015, 03:38:2820.02.15
an reacti...@googlegroups.com
Hi,

I have a ReactiveCommand bound to a XAML button like this:

XAML:
<Button Content="Update" HorizontalAlignment="Right" Command="{Binding CreateSeries}"/>

ViewModel:

public ReactiveCommand<IList<IChartSeriesViewModel>> CreateSeries { get; protected set; }

In ctor:
CreateSeries = ReactiveCommand.CreateAsyncTask(_ => CreateSeriesImpl());
CreateSeries.Subscribe(chartSeriesViewModels =>
{
    SeriesCollection = new ObservableCollection<IChartSeriesViewModel>(chartSeriesViewModels);
});

The async dummy task:
private async Task<IList<IChartSeriesViewModel>> CreateSeriesImpl()
{
    const int nSimulations = 100;
    IEnumerable<Task<Data>> readDataTasks = Enumerable.Range(0, nSimulations).Select(ReadData);
    Data[] datas = await Task.WhenAll(readDataTasks);
    return datas.Select(CreateChartSeries).ToList();
}

When I press my 'Update' button it id disabled as expected, however, it never gets enabled again even though the task finishes and my plots gets updated. Is there something I am forgetting? Shouldn't the button get enabled automagically when the task finishes?

Another thing, I tried using ReactiveList instead of ObservableCollection, but the plot would never update (SciChart by the way).

Sincerely
Atle 

Phil

ungelesen,
20.02.2015, 13:23:3020.02.15
an reacti...@googlegroups.com
How about like this?

CreateSeries = ReactiveCommand.CreateAsyncTask(_ async => {
SeriesCollection = new ObservableCollection<IChartSeriesViewModel>(await CreateSeriesImpl());
});

--
You received this message because you are subscribed to the Google Groups "ReactiveUI mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reactivexaml...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Phil
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten