Reputation: 127
I'm using the following xaml code to display a list horizontally,
<ListBox x:Name="List" HorizontalAlignment="Left" Height="429" Margin="18,83,0,0" VerticalAlignment="Top" Width="424" SelectionChanged="List_SelectionChanged_1">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Width="420" Height="80">
<TextBox x:Name="tbName" IsHitTestVisible="False" Height="70" Background="Green" Foreground="White" FontSize="22" BorderThickness="0" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
What I want exactly is:
after the TextBlock crosses the width it should be placed in the next line (Typically it should be like how we write in a paper).
i.e . until we reach the end of the StackPanel we will append the TextBox horizontally, but after the end of the StackPanel is reached we will place the next TextBox in the next line).
How can i do it??
Upvotes: 1
Views: 1159
Reputation: 3683
Here's the namespace:
xmlns:tlk="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
and there is how to use it:
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<tlk:WrapPanel></tlk:WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
Remember
You must reference: Microsoft.Phone.Controls.Toolkit.dll
Upvotes: 1
Reputation: 8231
try to add this code in your listBox:
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
the oriention of items depends on ItemsPanel.
Upvotes: 6