DivisionSoftware Blog |
El blog técnico de Eduardo Molteni sobre tecnología y software |
Recently I misunderstood a question in StackOverflow and begin to investigate if it is possible to show several items in the same line.
At first, I thought that you must show the items either vertically or horizontally, but that is not the case, you can change the full panel where the items are shown by changing the ItemsPanel
<ListBox ItemsSource=”{Binding}”>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation=”Horizontal” Width=”610” />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation=”Horizontal” Width=”200” Margin=”0”>
<TextBlock Text=”{Binding Path=NoteName}” Width=”120” />
<TextBlock Text=”{Binding Path=NoteDate, StringFormat=d}” Width=”80”/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
In this case, I change the Panel for a WrapPanel that allows me to show 3 items in the same line.
As an exercise to the reader: What margin or border prevents to set the width of the panel to 600?