前提
・WPFアプリ
・Visual Studio
・C#
実現したいこと
・ListBoxにおいてコンテンツを横1列に並べたい
上記のようなものを実現したいです。
現状
現在は↑のように縦に並んでおり、対応するxamlが以下です。
(listBoxのdataContextに配列をセットし、その要素を表示するリストになっています。要素数は変動します。)
<Grid Background="White"> <ListBox Name="dateListBox" Width="Auto" Height="Auto" HorizontalContentAlignment="Stretch" MouseUp="ListBox_MouseUp" ItemsSource="{Binding}" Margin="10,30,10,226"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Width="Auto" Height="Auto" Orientation="Horizontal" Background="AliceBlue"> <TextBlock Text="{Binding}" FontSize="20" TextAlignment="Center"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid>
HorizontalContentAlignment="Stretch"
を設定することで横にならぶのかなと思っていたのですが、上手くいかず、、、
アドバイス頂けると幸いです。
参考にしたもの
How to get a ListBox ItemTemplate to stretch horizontally the full width of the ListBox?

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/28 09:58