I am loading the contents to a listbox horizontally using the below layout.
The above will give me a list of buttons arranged horizontally inside a scrollbar. Now i want to position the scrollbar to the selected button ,
How can i set scroll position to an item in thehorizontal list ?
<ScrollViewer HorizontalScrollBarVisibility="Auto" Style="{StaticResource ResourceKey=customScrollViewer}" HorizontalContentAlignment="Center" HorizontalAlignment="Center"><ListBox ItemsSource="{Binding PagesCollection}" Name="lviewBookPages" Margin="5" BorderThickness="0" ><ListBox.ItemsPanel><ItemsPanelTemplate><WrapPanel Orientation="Horizontal"></WrapPanel></ItemsPanelTemplate></ListBox.ItemsPanel><ListBox.ItemTemplate><DataTemplate><ItemsControl><button/></ItemsControl> </DataTemplate></ListBox.ItemTemplate></ListBox>
The above will give me a list of buttons arranged horizontally inside a scrollbar. Now i want to position the scrollbar to the selected button ,
System.Windows.Controls.Primitives.Selector selector = lviewBookPages; (selector as ListBox).ScrollIntoView(selector.SelectedItem);I tried the above code , but not working . Is it because of
<ItemsPanelTemplate><WrapPanel Orientation="Horizontal"></WrapPanel></ItemsPanelTemplate>.
How can i set scroll position to an item in thehorizontal list ?
Thanks ***Share Knowledge to gain more***