Closed 3aIno closed 1 year ago
I have same Issue this is sample repo AListboxIssue.zip
@3aIno Have you found a workaround?
[RelayCommand]
private void SelectedExampleItemChanged()
{
Avalonia.Threading.Dispatcher.UIThread.Post( ()=>
Console.WriteLine(SelectedExampleItem));
}
It's Avalonia issue
I just created a pull request that fixes this issue. As wieslawsoltes suggested it was Avalonia control's issue. Please see AvaloniaUI/Avalonia pull request https://github.com/AvaloniaUI/Avalonia/pull/13503
Describe the bug
When using the ListBox control in an Avalonia MVVM application, it appears that the control is firing the SelectionChanged event before updating the SelectedItem property. This results in the SelectedItem property referencing the old value instead of the newly selected item. This is only happening when using EventTriggerBehavior, and the issue does not occur when handling the event in code-behind.
To Reproduce
Expected behavior The the SelectedItem property should be the item in the ListBox control which has just been selected, rather than the item it was prior to the selection change.
Desktop
Additional context This may be a similar issue to that being reported here.