WPF 禁用ItemControl 自动滚动

时间:2020-06-10 11:18:24   收藏:0   阅读:69

技术图片

 

 

禁用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;
}

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!