■ TextBlock 엘리먼트를 사용하는 방법을 보여준다. 각 예제는 단순 텍스트 블럭, 스타일 적용 텍스트 블럭, 다양한 속성 설정 텍스트 블럭, 인라인 텍스트 엘리먼트를 사용한 텍스트 블럭이다.
▶ MainPage.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 41 42 43 |
<?xml version="1.0" encoding="utf-8"?> <Page x:Class="TestProject.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" FontFamily="나눔고딕코딩" FontSize="16"> <Page.Resources> <Style TargetType="TextBlock" x:Key="CustomTextBlockStyleKey"> <Setter Property="FontFamily" Value="Comic Sans MS" /> <Setter Property="FontStyle" Value="Italic" /> </Style> </Page.Resources> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock Text="I am a TextBlock." /> <TextBlock Style="{StaticResource CustomTextBlockStyleKey}" Margin="0 30 0 0" Text="I am a styled TextBlock." /> <TextBlock Margin="0 30 0 0" Foreground="CornflowerBlue" FontFamily="Arial" FontSize="24" FontStyle="Italic" TextWrapping="WrapWholeWords" CharacterSpacing="200" Text="I am super excited to be here!" /> <TextBlock Margin="0 30 0 0"> <Run FontFamily="Times New Roman" Foreground="DarkGray"> Text in a TextBlock doesn't have to be a simple string. </Run> <LineBreak /> <Span>Text can be <Bold>bold</Bold>, <Italic>italic</Italic>, or <Underline>underlined</Underline>.</Span> </TextBlock> </StackPanel> </Page> |