Note that there are some explanatory texts on larger screens.

plurals
  1. POOne ScrollViewer for two ListBox
    primarykey
    data
    text
    <p>I've got 2 listbox and one scrollviewer and I want the scrollviewer to scroll the two listbox together. But i don't know how to do.. Here's my xaml :</p> <pre><code> &lt;ScrollViewer Grid.Row="1"&gt; &lt;Grid&gt; &lt;ListBox Name="listboxRSSFeedItems" Width="240" Height="644" Margin="0,0,240,0"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;TextBlock TextWrapping="Wrap" Text="{Binding Title}" Grid.Row="0" FontSize="24" HorizontalAlignment="Left" /&gt; &lt;HyperlinkButton Content="Link to details" NavigateUri="{Binding Link}" HorizontalAlignment="Left" Grid.Row="1" Margin="0,0,0,30" /&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;ListBox Name="listboxRSSFeedItems2" Width="240" Height="644" Margin="240,0,0,0"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;TextBlock TextWrapping="Wrap" Text="{Binding Title}" Grid.Row="0" FontSize="24" HorizontalAlignment="Left" /&gt; &lt;HyperlinkButton Content="Link to details" NavigateUri="{Binding Link}" HorizontalAlignment="Left" Grid.Row="1" Margin="0,0,0,30" /&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;/Grid&gt; &lt;/ScrollViewer&gt; </code></pre> <p>Thanks a lot</p> <hr> <p>Ok. I just tried to do one listbox with grid. it works fine, but how to choose which grid to add my item. I used to add with "listboxRSSFeedItems.Items.Add(item)", but now, how can i choose the 2nd Column only.</p> <pre><code> &lt;ScrollViewer Grid.Row="1"&gt; &lt;ListBox x:Name="listboxRSSFeedItems" Width="480" Height="680"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition /&gt; &lt;ColumnDefinition /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid x:Name="first" Grid.Column="0"&gt; &lt;TextBlock TextWrapping="Wrap" Text="{Binding Title}" /&gt; &lt;HyperlinkButton NavigateUri="{Binding URL}" TargetName="_blank"/&gt; &lt;/Grid&gt; &lt;Grid x:Name="second" Grid.Column="1"&gt; &lt;TextBlock TextWrapping="Wrap" Text="{Binding Title}" /&gt; &lt;HyperlinkButton NavigateUri="{Binding URL}" TargetName="_blank" /&gt; &lt;/Grid&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;/ScrollViewer&gt; </code></pre> <p>Thanks again</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload