Search This Blog

Showing posts with label Rectangle. Show all posts
Showing posts with label Rectangle. Show all posts

Wednesday, July 6, 2016

WPF Rectangle with Text

WPF > Rectangle > Add Text



<Window x:Class="Rectangle.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid  Height="22">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="50"/>
            <ColumnDefinition Width="300"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Rectangle Fill="Aqua"
                   Grid.Column="1"
                   HorizontalAlignment="Stretch"
                   />
        <TextBlock 
                   Foreground="Blue"
                   Grid.Column="1"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Text="Rectangle Text"
                   TextTrimming="CharacterEllipsis" />
    </Grid>
</Window>