Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectedItem setter is triggered for unchanged value in SelectingItemsControl #2807

Closed
jp2masa opened this issue Aug 2, 2019 · 1 comment
Labels

Comments

@jp2masa
Copy link
Contributor

jp2masa commented Aug 2, 2019

Repro

<ComboBox Items="{Binding Items}" SelectedItem="{Binding SelectedItem}" />
class ViewModel : ReactiveObject
{
    private string _selectedItem = "4";

    public IEnumerable<string> Items { get; } = Enumerable.Range(0, 5).Select(i => i.ToString()).ToArray();

    public string SelectedItem
    {
        get => _selectedItem;
        set => this.RaiseAndSetIfChanged(ref _selectedItem, value); // breakpoint here
    }
}

The breakpoint will be triggered on initialization, even though the selected item is correct and exists on Items.

Problem

The problem is comparing by reference here: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Base/Data/Core/SettableNode.cs#L45.

Replacing Object.ReferenceEquals with Object.Equals works as expected, but I'm not sure if this would be the correct behavior.

@grokys grokys added the bug label Oct 28, 2019
@MrJul
Copy link
Member

MrJul commented Apr 5, 2024

Fixed by #13970

@MrJul MrJul closed this as completed Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants