How do I set the selected item of a listbox?
When I use SelectedValue, SelectedItem, SelectedIndex, it does nothing. When I use UpdateLayout( ) afterwards, it does nothing. ScrollIntoView( item ) does not appear to do anything.
This is the XAML code for my Listbox. I use a Setter to set the orientation of the listbox to horizontal
<ScrollViewer HorizontalScrollBarVisibility="Visible" Name="DetailedWebViewContainer" VerticalScrollBarVisibility="Disabled" Grid.Row="2">
<ScrollViewer.Resources>
<Style TargetType="ListBox">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
</ScrollViewer.Resources>
<ListBox Name="WebScrollView" SelectionMode="Multiple" >
<ListBox.Items>
<phone:WebBrowser Name="LeftBrowser" MinWidth="460" Height="1500" IsHitTestVisible="False" Margin="10, 0, 10, 0"/>
<phone:WebBrowser Name="MiddleBrowser" MinWidth="460" Height="1500" IsHitTestVisible="False" Margin="10,0,10,10"/>
<phone:WebBrowser Name="RightBrowser" MinWidth="460" Height="1500" IsHitTestVisible="False" Margin="10,0,10,0" />
</ListBox.Items>
</ListBox>
</ScrollViewer>
Am I missing something? Greetz GeekPeek
This should work: