ViewModel: public ObservableCollection> TestSource { get; " /> ViewModel: public ObservableCollection> TestSource { get; " /> ViewModel: public ObservableCollection> TestSource { get; "/>

Fluent ribbon split button list update items source

546 views Asked by At

Xaml:

<fluent:SplitButton Icon="24.png" ItemsSource="{Binding TestSource}">

ViewModel:

public ObservableCollection<List<TestModel>> TestSource { get; set; }

Update Method:

public void UpdateSource(ObservableCollection<List<TestModel>> newSource)
{
    TestSource = newSource;
    OnPropertyChanged("TestSource");
}

It works fine the first time, but when assigning the TestSource property to a new object, the list displays the old list, and don't get updated.

1

There are 1 answers

0
Jonas On

I just had a similar problem here, with the same split button control and all.

First, I recommend changing the declaration of TestSource to:

public ObservableCollection<TestModel> TestSource { get; set; }

Next, do not assign a new ObjectCollection to TestSource.

Instead, try this:

public void UpdateSource(ObservableCollection<TestModel> newSource)
{
    TestSource.Clear();
    TestSource.AddRange(newSource);
    OnPropertyChanged("TestSource");
}

It seems like the ObjectCollection changes are only triggered when manipulating it with its methods, not direct assignments.