Results 1 to 2 of 2

Thread: [wpf / xaml] How do I make the font size increase when a text block is resized

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    [wpf / xaml] How do I make the font size increase when a text block is resized

    I have a text block in a frame that resizes when the form is resized but I'd like the text font to resize to fill the available area.

    I have :-
    Code:
    <Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Race Timer" Height="380" Width="571" Name="RaceTimerWindow">
        <Grid>
            <Button Content="Start" Height="48" HorizontalAlignment="Left" 
                    Margin="12,279,0,12" Name="Button_Start" 
                    VerticalAlignment="Bottom" Width="150" FontSize="20"  />
            <Button Content="Stop" Height="48" HorizontalAlignment="Right" Margin="378,279,12,12" 
                    Name="Button_Stop" VerticalAlignment="Bottom" Width="150" FontSize="20"  />
            <Grid  HorizontalAlignment="Stretch" Margin="12,12,12,85" 
                  Name="Grid_TimeClock" VerticalAlignment="Stretch"  Background="Black" >
                <TextBlock HorizontalAlignment="Stretch" Margin="12,6,12,12"  FontFamily="Arial" FontSize="64"
                           Name="ElapsedTimeDisplay" VerticalAlignment="Stretch" Background="Black" 
                           Foreground="Gold" TextAlignment="Center"  FontStretch="SemiExpanded">
                    <TextBlock.Text >
                        00:00:00
                    </TextBlock.Text> 
                </TextBlock>
            </Grid>
        </Grid>
    </Window>

  2. #2
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: [wpf / xaml] How do I make the font size increase when a text block is resized

    If your ok with the font increasing well then a viewbox is what you want.

    http://msdn.microsoft.com/en-us/libr...s.viewbox.aspx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width