一、如何让DataGrid在选择项发生切换时,滚动条自动滚动到选择项所在位置。步骤如下:
1.订阅选择项切换事件(this代表当前的Datagrid)
this.SelectionChanged += DataGridForScrollToSelected_SelectionChanged;
2.选择项切换事件的方法中添加滚动条滚动的代码
private void DataGridForScrollToSelected_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (this.SelectedItem != null)
{
this.ScrollIntoView