AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.87k stars 2.24k forks source link

Combobox selectedValue in datagrid is changed when scrolling datagrid #13751

Open yaobiao131 opened 11 months ago

yaobiao131 commented 11 months ago

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

image

Environment

Additional context

Add any other context about the problem here.

yaobiao131 commented 11 months ago

and If I modify the selected value of the combobox and then scroll it, the selected value will go to other rows.

jpgarza93 commented 11 months ago

I am having the same issue

jpgarza93 commented 11 months ago

My current work around (i am using MVVM) is to check if selected index is -1. If so (for me) it means it was changed by the datagrid and not the user

set
 {
     if (value != -1)
     {
         _selectedIndex = value;
         OnPropertyChanged(nameof(SelectedIndex));
    }
 }
yaobiao131 commented 11 months ago

My current work around (i am using MVVM) is to check if selected index is -1. If so (for me) it means it was changed by the datagrid and not the user

set
 {
     if (value != -1)
     {
         _selectedIndex = value;
         OnPropertyChanged(nameof(SelectedIndex));
    }
 }

it work well, thanks

timunie commented 11 months ago

Can you attach a minimum sample please? We recently had a similar issue which was solved as a binding was simply wrong

blueperspective commented 11 months ago

Same problem here, I tried to do a minimal repo sample DataGridTest. You need to click "enrich" button to set the combobox values (did this because it mimics what I have on a bigger app) ;

What I get :

I could not reproduce what I have on my bigger, which is the last 2-3 lines which changes SelectedValue every time I scroll them out and then in.

timunie commented 11 months ago

@blueperspective great sample 👍 Added it to our roll-up list. @grokys