Если я правильно понял ваш запрос:
- Вы не на самом деле хотите, чтобы ListView прокрутил ваши данные до центра
- Вы do хотите, чтобы полоса прокрутки в ListView выглядела иначе
Например, если вы используете GridView и хотите, чтобы горизонтальная полоса прокрутки была преобразована в кнопки слеваи справа от вашего взгляда вы можете оформить его следующим образом:
<Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="{x:Type ScrollViewer}">
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<DockPanel Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<RepeatButton DockPanel.Dock="Left"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
Command="{x:Static ScrollBar.LineLeftCommand}"
Content="{StaticResource ScrollLeftArrow}"/>
<RepeatButton DockPanel.Dock="Right"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
Command="{x:Static ScrollBar.LineRightCommand}"
Content="{StaticResource ScrollRightArrow}"/>
<ScrollBar DockPanel.Dock="Right"
Name="PART_VerticalScrollBar"
Orientation="Vertical"
Minimum="0.0"
Maximum="{TemplateBinding ScrollableHeight}"
ViewportSize="{TemplateBinding ViewportHeight}"
Value="{Binding Path=VerticalOffset,RelativeSource={RelativeSource TemplatedParent},Mode=OneWay}"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
Cursor="Arrow"/>
<ScrollBar DockPanel.Dock="Bottom"
Name="PART_HorizontalScrollBar"
Visibility="Hidden"
Orientation="Horizontal" />
<DockPanel Margin="{TemplateBinding Padding}">
<ScrollViewer DockPanel.Dock="Top"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden"
Focusable="false">
<GridViewHeaderRowPresenter Margin="2,0,2,0"
Columns="{Binding Path=TemplatedParent.View.Columns,RelativeSource={RelativeSource TemplatedParent}}"
ColumnHeaderContainerStyle="{Binding Path=TemplatedParent.View.ColumnHeaderContainerStyle,RelativeSource={RelativeSource TemplatedParent}}"
ColumnHeaderTemplate="{Binding Path=TemplatedParent.View.ColumnHeaderTemplate,RelativeSource={RelativeSource TemplatedParent}}"
ColumnHeaderTemplateSelector="{Binding Path=TemplatedParent.View.ColumnHeaderTemplateSelector,RelativeSource={RelativeSource TemplatedParent}}"
AllowsColumnReorder="{Binding Path=TemplatedParent.View.AllowsColumnReorder,RelativeSource={RelativeSource TemplatedParent}}"
ColumnHeaderContextMenu="{Binding Path=TemplatedParent.View.ColumnHeaderContextMenu,RelativeSource={RelativeSource TemplatedParent}}"
ColumnHeaderToolTip="{Binding Path=TemplatedParent.View.ColumnHeaderToolTip,RelativeSource={RelativeSource TemplatedParent}}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
<ScrollContentPresenter Name="PART_ScrollContentPresenter"
KeyboardNavigation.DirectionalNavigation="Local"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CanContentScroll="{TemplateBinding CanContentScroll}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</DockPanel>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Для этого нужно изменить шаблон ScrollViewer, используемый в GridView, на:
- Две кнопки повтора, закрепленныевлево и вправо и используется для прокрутки влево и вправо
- Вертикальная полоса прокрутки в случае, если требуется вертикальная прокрутка
- Скрытая горизонтальная полоса прокрутки для соответствия ScrollViewer (зависит от реально существующей полосы прокрутки)) и
- Обычное содержимое GridView, состоящее из заголовка и данных
Подобные методы применимы к ListBox и т. д., за исключением ScШаблон rollViewer проще, потому что ему не нужно иметь дело со строками заголовков.
Если вы объясните точный макет, который вы хотите, когда прокрутка включена (картинка была бы хороша), я могу дать вамлучше ответь.Это также может помочь увидеть ваш существующий XAML.