I have a horizontal ListBox. Here is the code for it (some irrelevant ones removed):
<ListBox Grid.Row="1"
ItemContainerStyle="{StaticResource ListBoxUnselectableItemStyle}"
ItemsSource="{Binding ...}"
BorderThickness="0"
Background="{x:Null}"
ScrollViewer.CanContentScroll="False">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"
VerticalAlignment="Top"
HorizontalAlignment="Center"
Background="Red"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
And I get the layout behavior of the elements as follows:
]
As you can see, the second element is smaller and the VerticalLayout is not the top as I want.
Can someone help me?
source
share