ListBox์˜ FontSize..

์Œโ€ฆ์ผ๋‹จโ€ฆ์‚ฌ์ง„์„ ์˜ฌ๋ฆฌ๋ ค๊ณ  ํ–ˆ๋Š”๋ฐโ€ฆ์‚ฌ์ง„์„ ์–ด๋–ป๊ฒŒ ์˜ฌ๋ ค์•ผ ํ•˜๋Š”์ง€ ๋ชจ๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค.

'|------------------------------|
'| item1 |
'| item2 |
'| item3 |
'|------------------------------|

์œ„์™€ ๊ฐ™์ด ์žˆ๋Š”๋ฐ,


<Style x:Key="FontSelectorListBox" TargetType="ListBox" BasedOn="{StaticResource ListBoxBase}">
    <Setter Property="Foreground" Value="White"/>
    <Setter Property="ItemContainerStyle">
        <Setter.Value>
            <Style TargetType="ListBoxItem">
                <Setter Property="FontSize" Value="20"/>
            </Style>
        </Setter.Value>
    </Setter>
</Style>

Style์„ ์ด์™€ ๊ฐ™์ด ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.
๋‹น์—ฐํžˆ Style=โ€œ{StaticResource FontSelectorListBox}โ€ ์™€ ๊ฐ™์ด Style์„ ์ง€์ •ํ•ด ์คฌ๊ตฌ์š”.
๊ทธ๋Ÿฐ๋ฐโ€ฆFontSize๊ฐ€ ๋ณ€๊ฒฝ์ด ๋˜์งˆ ์•Š์Šต๋‹ˆ๋‹ค.
ํ˜น์‹œ ๋ญ๊ฐ€ ๋ฌธ์ œ์ธ์ง€ ์ข€ ๋ด์ฃผ์‹ค๋ถ„ ์•ˆ๊ณ„์‹ ๊ฐ€์š”?
์ •๋ง ๋Œ์•„๋ฒ„๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค. ๋ถ€ํƒ ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

  1. ListBoxBase ์Šคํƒ€์ผ ๋ฆฌ์†Œ์Šค์˜ ์ •์˜๋Š” ์–ด๋–ป๊ฒŒ ๋˜๋‚˜์š”? ํ•ด๋‹น ์Šคํƒ€์ผ์—์„œ ItemTemplate ์†์„ฑ์„ ์ง€์ •ํ–ˆ์œผ๋ฉฐ, ๊ทธ ์•ˆ์—์„œ FontSize ์†์„ฑ์„ ์ง€์ •
  2. ๋˜๋Š” ์ด FontSelectorListBox ์Šคํƒ€์ผ์„ ์‚ฌ์šฉํ•˜๋Š” ListBox์—์„œ ItemTemplate ์†์„ฑ์„ ์ง€์ •ํ–ˆ์œผ๋ฉฐ, ๊ทธ ์•ˆ์—์„œ FontSize ์†์„ฑ์„ ์ง€์ •

๋‘˜ ์ค‘ ํ•˜๋‚˜์ด์ง€ ์•Š์„๊นŒ ํ•˜๋Š” ์ถ”์ธก์„ ํ•ด๋ด…๋‹ˆ๋‹ค.

1 Like

์ €๋Š” list view ์“ฐ๋Š”๋ฐ GridViewColumnHeader๋ฅผ TargetType์œผ๋กœ ์žก๊ณ  ํฐํŠธ ์กฐ์ ˆํ•˜๊ณ  listview์— ItemContainerStyle=โ€œ{StaticResource CustomListViewItemStyle}โ€ ์ด๋ ‡๊ฒŒ ๋„ฃ์–ด์„œ ์“ฐ๊ณ  ์žˆ๋„ค์š”

1 Like

์ผ๋‹จ ์ด๋ ‡๊ฒŒ ํ•ด๊ฒฐ ํ–ˆ์Šต๋‹ˆ๋‹ค.
XAMLํŒŒ์ผ์—์„œ ์ด๋ ‡๊ฒŒ ํ–ˆ๊ตฌ์š”โ€ฆ

    <ListBox x:Name="FontListBox" ItemsSource="{Binding Fonts}" SelectedItem="{Binding SelectedFont, Mode=TwoWay}" Grid.Row="1" Grid.Column="0" Style="{StaticResource FontSelectorListBox}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Name}" FontFamily="{Binding FontFamilly}" Style="{StaticResource FontSelectorTextBlock}"/>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

๊ทธ๋ฆฌ๊ณ  Style ํŒŒ์ผ์—์„œ ์ด๋ ‡๊ฒŒ ํ–ˆ์Šต๋‹ˆ๋‹ค.

<Style x:Key="FontSelectorTextBlock" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBase}">
    <Setter Property="FontSize" Value="36"/>
</Style>

์ด๊ฒŒ ์ •์ƒ์ ์ธ ๋ฐฉ๋ฒ•์ธ์ง€๋Š” ๋ชจ๋ฅด๊ฒ ์ง€๋งŒโ€ฆ ์ด๋ ‡๊ฒŒ ๋ชฉ์ ์€ ์ด๋ค˜์Šต๋‹ˆ๋‹ค.

1 Like