WPF 禁用ItemControl 自动滚动

 

 

禁用FameworkElement中的RequestBringIntoViewEvent事件即可,

Xaml:

<ListBox >
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<EventSetter Event="RequestBringIntoView" Handler="ListBoxItem_RequestBringIntoView"></EventSetter>
</Style>
</ListBox.ItemContainerStyle>

</ListBox >

 

后台事件:

private void ListBoxItem_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
{
e.Handled = true;
}

 

posted @ 2020-06-10 10:24  海华风光  阅读(454)  评论(0)    收藏  举报