Search This Blog

Thursday, July 28, 2016

GridSplitter WPF Example

WPF > Controls  > GridSplitter 




<Window x:Class="GridSplitter.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>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="2" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="TextBlock1" VerticalAlignment="Top" Grid.Column="0"/>
        <GridSplitter Grid.Column="1" Width="2" HorizontalAlignment="Stretch" />
        <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="TextBlock2" VerticalAlignment="Top" Grid.Column="2"/>
    </Grid>
</Window>


Wednesday, July 6, 2016

TextBlock WPF Example

WPF > Controls  > TextBlock 

TextBlock can contain a string in its Text property.

TextBlock is designed to be lightweight and is optimized for single-line display.

Example


<Window x:Class="TextBlock.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>
        <TextBlock Name="textBlock1" TextWrapping="Wrap">
            Simple text <Bold>Bold text</Bold> <Italic>Italic text</Italic>
        </TextBlock>
    </Grid>

</Window>

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>

Tuesday, July 5, 2016

WPF DependencyProperty Register Default Value

WPF > DependencyPropertyRegister > Default Value



public static readonly DependencyProperty
UpdateSourceTriggerProperty = DependencyProperty.Register("UpdateSourceTrigger", typeof(UpdateSourceTrigger),
typeof(TextBox),
new FrameworkPropertyMetadata(UpdateSourceTrigger.LostFocus)); // add your default value here