WPF SelectedItem and Scrolling
I have a WPF DataGrid. The DataGrid is bound to an IList. The list has many many items so the DataGrid MaxHeight is set to a predefined value and the DataGrid automatically displays a scroll bar. The selection mode and unit are set to "single full row".
The form has a button called "New" that adds an item to the list that the datagrid is bound to.After "New" is clicked, the new item should be the new selected item. I do this via : dataGrid.SelectedItem = newItem;
This works ..but not 开发者_Go百科as well as I expect it to.
I also want the dataGrid to scroll down to the newly selected item .. Any idea on how to do this ?
Regards, MadSEB
After you set the SelectedItem, make sure to call DataGrid.ScrollIntoView with the new item. This will make sure that the new item is visible on screen.
精彩评论