【发布时间】:2014-04-01 04:57:23
【问题描述】:
我有以下ItemsControl:
<ItemsControl ItemsSource="{Binding Model.XList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
在他们每个人上应用以下模板:
<DataTemplate DataType="{x:Type model:MyModelType}">
<Border MaxWidth="140">
<local:SingleView DataContext="{Binding}"/>
</Border>
</DataTemplate>
实际上使它们每个都为“SingleView”控件。
包裹在ScrollViewer中的ItemsControl。
当我有大量的项目(滚动似乎),并且我按下控件的任何按钮时,屏幕会跳转(可能是因为获得焦点的滚动发生了变化)。
我想避免跟随焦点滚动。
我已经看到通过 RequestBringIntoView 事件通过 Code-Behind 实现的解决方案。
但我正在与 MVVM 合作,有人对此有解决方案吗?
【问题讨论】:
-
I've seen solutions that make it through the Code-Behind, by RequestBringIntoView event.- 你能展示这个解决方案吗? -
@AnatoliyNikolaev,看这里:stackoverflow.com/questions/209416/…
-
你试过
ScrollViewer.CanContentScroll="False"换ItemsControl吗?你见过this方法吗?此方法适用于 MVVM。
标签: wpf mvvm scroll itemscontrol