Skip to content

Instantly share code, notes, and snippets.

@droyad
Created July 3, 2012 01:24
Show Gist options
  • Save droyad/3036888 to your computer and use it in GitHub Desktop.
Save droyad/3036888 to your computer and use it in GitHub Desktop.
<Window x:Class="WpfApplication2.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">
<Window.Resources>
<!-- These can go into the global styles-->
<Style TargetType="{x:Type Label}">
<Setter Property="TextBlock.TextAlignment" Value="Right" />
<Setter Property="Margin" Value="5,5,10,5" />
</Style>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}" >
<Setter Property="Margin" Value="5,5,10,5" />
</Style>
</Window.Resources>
<Grid>
<Grid.Resources>
<Style x:Key="RightAlignTextBox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}" >
<Setter Property="TextBlock.TextAlignment" Value="Right" />
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0" Content="Text" />
<TextBox Style="{StaticResource RightAlignTextBox}" Grid.Column="1" Grid.Row="0" Text="Text" />
<Label Grid.Column="0" Grid.Row="1" Content="Text" />
<TextBox Grid.Column="1" Grid.Row="1" Text="Text" />
<Label Grid.Column="0" Grid.Row="2" Content="Text" />
<TextBox Grid.Column="1" Grid.Row="2" Text="Text" />
<Label Grid.Column="0" Grid.Row="3" Content="Text" />
<TextBox Grid.Column="1" Grid.Row="4" Text="Text" />
</Grid>
</Window>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment