■ ListBox 엘리먼트의 ItemsPanel 속성에 WrapPanel을 사용하는 방법을 보여준다.
▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<ListBox xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" Height="200" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <controls:WrapPanel /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBoxItem>가격 결정</ListBoxItem> <ListBoxItem>가격 변동 준비금</ListBoxItem> <ListBoxItem>가격 분석</ListBoxItem> <ListBoxItem>가격 수준</ListBoxItem> <ListBoxItem>가격 인상</ListBoxItem> <ListBoxItem>가격 인상률</ListBoxItem> <ListBoxItem>가격 인하</ListBoxItem> </ListBox> |
※ ListBox 엘리먼트 ItemsPanel 속성에 WrapPanel을 갖는 ItemsPanelTemplate 엘리먼트를 설정하는 경우 WrapPanel의 넓이가 ListBox의 넓이에 고정되어야 하기 때문에 ScrollViewer.HorizontalScrollBarVisibility 첨부 속성을 반드시 Disabled로 설정해야 한다.