如何阻止点击scrollviewer里面的单位内容时,自动滚动

 1 <Style TargetType="{x:Type ListBoxItem}">
 2 <Setter Property="FocusVisualStyle" Value="{x:Null}" />
 3 <Setter Property="Background" Value="Transparent" />
 4 <EventSetter Event="RequestBringIntoView" Handler="OnRequestBringIntoView" />//这句话起作用
 5 <Setter Property="Template">
 6 <Setter.Value>
 7 <ControlTemplate TargetType="{x:Type ListBoxItem}">
 8 
 9 <ContentPresenter HorizontalAlignment="Stretch"
10 VerticalAlignment="Stretch"
11 SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
12 </ControlTemplate>
13 </Setter.Value>
14 </Setter>
15 </Style>
1 //cs代码
2 private void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
3         {
4             e.Handled = true;
5         }

 

posted on 2017-09-12 16:56  Shine-Zhong  阅读(230)  评论(0)    收藏  举报

导航