■ ListBox 엘리먼트의 ItemContainerStyle 속성을 사용하는 방법을 보여준다.
▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
<Grid x:Name="_pGrid" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" Background="White"> <Grid.Resources> <Style x:Key="ListBoxItemStyleKey" TargetType="ListBoxItem"> <Setter Property="Margin" Value="5" /> <Setter Property="BorderBrush" Value="DarkGray" /> <Setter Property="BorderThickness" Value="2" /> <Setter Property="Background" Value="Blue" /> <Setter Property="Foreground" Value="White" /> <Setter Property="FontSize" Value="14" /> <Setter Property="FontWeight" Value="Bold" /> </Style> </Grid.Resources> <ListBox HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" Height="200" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemContainerStyle="{StaticResource ListBoxItemStyleKey}"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <controls:WrapPanel /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBoxItem>가격 결정</ListBoxItem> <ListBoxItem>가격 변동 준비금</ListBoxItem> <ListBoxItem>가격 분석</ListBoxItem> <ListBoxItem>가격 수준</ListBoxItem> <ListBoxItem>가격 인상</ListBoxItem> <ListBoxItem>가격 인상률</ListBoxItem> <ListBoxItem>가격 인하</ListBoxItem> </ListBox> </Grid> |