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

Setting SelectedItem before ItemsSource is not working properly for SelectingItemsControls #18147

Open
tvass83 opened this issue Feb 7, 2025 · 0 comments
Labels

Comments

@tvass83
Copy link

tvass83 commented Feb 7, 2025

Describe the bug

In Avalonia 11.2.3, the following sequence of operations does not work as opposed to using v0.10.22:

  1. Bind your SelectedItem & ItemsSource to viewmodel (VM) properties
  2. set the SelectedItem via the VM
  3. populate ItemsSource via the VM
  4. raise a propertychanged for the selected item VM property

There are two ways to approach this:

  1. In WPF, as soon as you populate the ItemsSource, it automatically respects the previously set SelectedItem
  2. This is a regression introduced by Binding System refactor #13970, where a forced raisepropertychanged is being short-circuit due to a check if the value changed at all, here:
    if (property.IsDirect)
    {
    if (hasValueChanged)
    property.RouteSetDirectValueUnchecked(Owner, value);

In my opinion, the WPF behavior would be the preferred one here, what do you guys think?

To Reproduce

Please check the following simple repro apps:
https://github.com/tvass83/AvaloniaIssues/tree/main/SelectedItemOrder

Expected behavior

No response

Avalonia version

11.2.3

OS

Windows

Additional context

No response

@tvass83 tvass83 added the bug label Feb 7, 2025
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

1 participant