Describe the bug
When binding two controls two one object (e.g. to have one SelectedItem for two ListBoxes), updating the value causes an infinite loop.
To Reproduce
ViewModel:
public class MainWindowViewModel : ViewModelBase
{
private MyModel _selectedModel;
private IEnumerable<MyModel> Items { get; } = new[]
{
new MyModel(1, "First entry"),
new MyModel(2, "Second entry"),
new MyModel(3, "Third entry"),
new MyModel(4, "Fourth entry"),
};
public MyModel SelectedModel
{
get => _selectedModel;
set => this.RaiseAndSetIfChanged(ref _selectedModel, value);
}
}
public record MyModel(int Id, string Name);
Describe the bug When binding two controls two one object (e.g. to have one
SelectedItem
for two ListBoxes), updating the value causes an infinite loop.To Reproduce ViewModel:
View:
Click on any of the
ListBoxItem
s to trigger the infinite loop.Expected behavior The selected value of the
ListBox
is displayed in theTextBlock
.Desktop (please complete the following information):
Additional context May be related to #4438
When removing
Mode=OneWayToSource
from one of the controls, it works, however then the lists are synchronized.When implementing the
INotifyPropertyChanged
pattern myself, the problem still occurs which suggests ReactiveUI is not the problem.