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.36k stars 2.2k forks source link

DataGrid - Add property "AutoScrollToSelectedItem" #6513

Open EtherGhost opened 3 years ago

EtherGhost commented 3 years ago

Is your feature request related to a problem? Please describe. Enhancement

Describe the solution you'd like Add property "AutoScrollToSelectedItem".

Describe alternatives you've considered

private bool flag;

private void HandleSelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (flag)
    {
        _dataGrid.ScrollIntoView(_dataGrid.SelectedItem, null);
        return;
    }

    flag = true;
}

Additional context Add any other context or screenshots about the feature request here.

morphinapg commented 1 year ago

On a related note, ScrollIntoView doesn't quite scroll to the exact item for me. I have thousands of dates worth of data in my grid, with 6/25/2023 as the last date in the list, and when I use ScrollIntoView for the final item, it shows the 6/18/2023 item instead. So in order for "AutoScrollToSelectedItem" to work, ScrollIntoView would also need to be fixed.