programming-examples/c-sharp/Others/Font Viewer.cs
2019-11-15 12:59:38 +01:00

51 lines
2.1 KiB
C#

Font Viewer
<Window x:Class="FontViewer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Teach Yourself WPF: Font Viewer"
Height="500"
Width="700">
<DockPanel Margin="9">
<ListBox x:Name="FontList"
DockPanel.Dock="Left"
ItemsSource="{x:Static Fonts.SystemFontFamilies}"
Width="160" />
<TextBox x:Name="SampleText"
DockPanel.Dock="Bottom"
MinLines="4"
Margin="8 0"
TextWrapping="Wrap">
<TextBox.ToolTip>
<TextBlock>
<Italic Foreground="Red">Instructions: </Italic> Type here to change the preview text.
</TextBlock>
</TextBox.ToolTip>
The quick brown fox jumps over the lazy dog.
</TextBox>
<StackPanel Margin="8 0 8 8">
<TextBlock Text="{Binding ElementName=SampleText, Path=Text}"
FontFamily="{Binding ElementName=FontList,Path=SelectedItem}"
FontSize="12"
TextWrapping="Wrap"
Margin="0 0 0 4" />
<TextBlock Text="{Binding ElementName=SampleText, Path=Text}"
FontFamily="{Binding ElementName=FontList,Path=SelectedItem}"
FontSize="18"
TextWrapping="Wrap"
Margin="0 0 0 4" />
<TextBlock Text="{Binding ElementName=SampleText, Path=Text}"
FontFamily="{Binding ElementName=FontList,Path=SelectedItem}"
FontSize="25"
TextWrapping="Wrap"
Margin="0 0 0 4" />
<TextBlock Text="{Binding ElementName=SampleText, Path=Text}"
FontFamily="{Binding ElementName=FontList,Path=SelectedItem}"
FontSize="36"
TextWrapping="Wrap" />
</StackPanel>
</DockPanel>
</Window>