0

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.

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
IBRA
  • 1,502
  • 3
  • 24
  • 56

1 Answers1

0

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.

Jonas
  • 1,172
  • 1
  • 16
  • 26