#4456·ReactiveUI

[Bug]: WPF thread error in v24

Author: HakoyuCreated Sep 8, 2026Updated Sep 11, 2026
Labelsbug

Describe the bug

CollectionView of this type does not support changes to its SourceCollection from threads other than the dispatcher thread.

Step to reproduce

Start WPF and trigger WhenAnyValue

csharp
public partial class MainWindow : Window, IViewFor<MainViewModel>
{
    public MainViewModel? ViewModel { get; set; }
    object? IViewFor.ViewModel
    {
        get => ViewModel;
        set => ViewModel = (MainViewModel)value!;
    }

    public MainWindow()
    {
        InitializeComponent();

        RxAppBuilder.CreateReactiveUIBuilder().WithWpf().BuildApp();
        DataContext = ViewModel = new();
        Loaded += MainWindow_Loaded;
    }

    private void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
        this.Bind(ViewModel, vm => vm.Text, v => v.TextBox.Text);
        this.Bind(ViewModel, vm => vm.Strings, v => v.ListBox.ItemsSource);
    }
}

public class MainViewModel : ReactiveObject
{
    public MainViewModel()
    {
        this.WhenAnyValue(x => x.Text)
            .Throttle(TimeSpan.FromSeconds(1), RxSchedulers.TaskpoolScheduler)
            .Where(x => string.IsNullOrWhiteSpace(x) is false)
            .ObserveOn(RxSchedulers.MainThreadScheduler)
            .Subscribe(x => Strings.Add(x));
    }

    public string Text
    {
        get;
        set => this.RaiseAndSetIfChanged(ref field, value, nameof(Text));
    }

    public ObservableCollection<string> Strings { get; set; } = new();
}

WpfApp1.zip

Reproduction repository

https://github.com/reactiveui/ReactiveUI

Expected behavior

Strings can be used normally with the Add method. This code can works fine in ReactiveUI v23.2.28.

Screenshots ️

Image

IDE

No response

Operating system

No response

Version

No response

Device

No response

ReactiveUI Version

24.2.0

Additional information ℹ️

No response