C
C
crescent2021-10-28 13:11:54
WPF
crescent, 2021-10-28 13:11:54

c# wpf listview how to prevent arrow from jumping?

There is a wpf listview
if you press the arrows on the keyboard, then by default the select item will change
how to make it so that when the last element is selected - in the far one it does NOT jump to the first one but remains there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AndromedaStar, 2021-10-28
@AndromedaStar

private void listView_PreviewKeyDown(object sender, KeyEventArgs e)
    {
        switch(e.Key)
        {
            case Key.Down:
                //здесь логика сравнения - сейчас последний элемент или нет, 
                //если последний то e.Handled = true
                break;
            default:
                break;
        }
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question