Font Viewer using XAML

Questions about programming languages and debugging
Post Reply
User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1624
Joined: 28 Aug 2005, 16:00
18

Font Viewer using XAML

Post by maboroshi »

This is a font viewer using XAML in WPF which I got from a book. I thought it would be handy. Here is a link to the Visual Studio Project File includes a binary. Needs .net 4

http://www.techshinobi.com/source/FontViewer.zip

Image

Code: Select all

<Window x:Class="FontViewer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Font Viewer" Height="400" Width="600">
    <DockPanel>
        
        <Border DockPanel.Dock="Top" CornerRadius="6"
                BorderThickness="1" BorderBrush="Gray"
                Background="LightGray" Padding="8" 
                Margin="0 0 0 8">
        
            <TextBlock FontSize="14"
                       TextWrapping="Wrap">
                Select a font to view from the list below.
                You can change the text by typing in the region at the bottom.
            </TextBlock>
        </Border>
        <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"
                 ToolTip="Type Here to change the preview text.">
            The quick brown Fox jumped over the lazy dog.
        </TextBox>
        <TextBlock Text="{Binding ElementName=SampleText, Path=Text}"
                   FontFamily="{Binding ElementName=FontList, Path=SelectedItem}"
                   TextWrapping="Wrap"
                   Margin="0 0 0 4" />
        
    </DockPanel>
</Window>

Post Reply