Grid UI layout for a database I've spent a few days making the transition from WinForms to WPF, and do not have much time for tutorials as the work needs to be done quickly.  I was wondering if anyone could take a look at a sample of my code and point out any conventions that I'm missing (and that are commonplace in modern WPF usage).  I've picked a random sample of some XAML code which I've written:

&lt;Window x:Class=""
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         Width="300" Height="300"&gt;
    &lt;Window.Resources&gt;
        &lt;Style x:Key="buttonsStyle" TargetType="Button"&gt;
            &lt;Setter Property="Height" Value="25"/&gt;
            &lt;Setter Property="Width" Value="80"/&gt;
        &lt;/Style&gt;
        &lt;Style x:Key="componentsStyle" TargetType="Control"&gt;
            &lt;Setter Property="Height" Value="20"/&gt;
            &lt;Setter Property="Width" Value="190"/&gt;
        &lt;/Style&gt;
        &lt;Style x:Key="labelStyle" TargetType="Label"&gt;
            &lt;Setter Property="VerticalAlignment" Value="Center"/&gt;
        &lt;/Style&gt;
    &lt;/Window.Resources&gt;
    &lt;StackPanel Orientation="Vertical"&gt;
        &lt;Grid&gt;
            &lt;Grid.RowDefinitions&gt;
                &lt;RowDefinition&gt;
                &lt;/RowDefinition&gt;
                &lt;RowDefinition&gt;
                &lt;/RowDefinition&gt;
                &lt;RowDefinition&gt;
                &lt;/RowDefinition&gt;
                &lt;RowDefinition&gt;
                &lt;/RowDefinition&gt;
                &lt;RowDefinition&gt;
                &lt;/RowDefinition&gt;
            &lt;/Grid.RowDefinitions&gt;
            &lt;Grid.ColumnDefinitions&gt;
                &lt;ColumnDefinition Width="70"&gt;
                &lt;/ColumnDefinition&gt;
                &lt;ColumnDefinition Width="200"&gt;
                &lt;/ColumnDefinition&gt;
            &lt;/Grid.ColumnDefinitions&gt;
            &lt;Label Grid.Column="0" Grid.Row="0" Style="{StaticResource labelStyle}"&gt;Server:&lt;/Label&gt;
            &lt;ComboBox Grid.Column="1" Grid.Row="0" Name="cmbServer" Style="{StaticResource componentsStyle}"/&gt;
            &lt;CheckBox Name="chkWindowsAuthentication" Grid.Column="0" Grid.Row="1" IsChecked="False"/&gt;
            &lt;Label Grid.Column="1" Grid.Row="1" Style="{StaticResource labelStyle}"&gt;Use Windows Authentication&lt;/Label&gt;
            &lt;Label Grid.Column="0" Grid.Row="2" Style="{StaticResource labelStyle}"&gt;Username:&lt;/Label&gt;
            &lt;TextBox Grid.Column="1" Grid.Row="2" Name="txtUsername" Style="{StaticResource componentsStyle}"/&gt;
            &lt;Label Grid.Column="0" Grid.Row="3" Style="{StaticResource labelStyle}"&gt;Password:&lt;/Label&gt;
            &lt;PasswordBox Grid.Column="1" Grid.Row="3" Name="txtPassword" Style="{StaticResource componentsStyle}"/&gt;
            &lt;Label Grid.Column="0" Grid.Row="4" Style="{StaticResource labelStyle}"&gt;Database:&lt;/Label&gt;
            &lt;ComboBox Grid.Column="1" Grid.Row="4" Name="cmbDatabase" Style="{StaticResource componentsStyle}"/&gt;
        &lt;/Grid&gt;
        &lt;StackPanel Orientation="Horizontal" Margin="10,30,10,10"&gt;
            &lt;Button Margin="0,0,10,0" Style="{StaticResource buttonsStyle}"&gt;Connect&lt;/Button&gt;
            &lt;Button Style="{StaticResource buttonsStyle}"&gt;Reset&lt;/Button&gt;
        &lt;/StackPanel&gt;
    &lt;/StackPanel&gt;
&lt;/Window&gt;


The code is functional and displays the proper result, however I am worried that I am not using the right techniques.  Any input at all is greatly appreciated.
All in all, your code is quite well-structured. Here are a couple of suggestions for improvement:


Consider moving your styles to a resource dictionary:

&lt;Window.Resources&gt;
    &lt;ResourceDictionary Source="Resources.xaml" /&gt;
&lt;/Window.Resources&gt;


This will de-clutter your file and allow you to re-use the styles in other windows. 
Collapse empty tags (use the self-closing syntax):

&lt;Grid.RowDefinitions&gt;
    &lt;RowDefinition /&gt;
    &lt;RowDefinition /&gt;
    &lt;RowDefinition /&gt;
    &lt;RowDefinition /&gt;
    &lt;RowDefinition /&gt;
&lt;/Grid.RowDefinitions&gt;


(the same goes for the ColumnDefinitions and any other empty tags)
Declare styles that affect all controls of one type without a key:

&lt;Style TargetType="Button"&gt; ... &lt;/Style&gt;
&lt;Style TargetType="Label"&gt; ... &lt;/Style&gt;


That way, you don't seperately have to set all the labels to labelStyle and all the  buttons to buttonsStyle, just remove all occurences of the following two attributes:

Style="{StaticResource labelStyle}"
Style="{StaticResource buttonsStyle}"

The default value of Grid.Column and Grid.Row is 0, you can get away without setting it explicitly. And CheckBox.Checked is false by default. So you can remove all occurences of the following:

Grid.Column="0" 
Grid.Row="0" 
IsChecked="False"

Generally, in WPF, widths and heights are not explicitly stated. You should try to use relative and automatic dimensions where possible (which often requires choosing the correct container).
For instance, you could use relative sizing for your grid columns:

&lt;Grid.ColumnDefinitions&gt;
    &lt;ColumnDefinition Width="0.35*" /&gt;
    &lt;ColumnDefinition Width="*" /&gt;
&lt;/Grid.ColumnDefinitions&gt;


In other situations, working with Margin can be a replacement for explicit pixel sizes. Remember that hard-coded sizes are an obstacle to localization (where long words in foreign languages are cropped) and less flexible.


These suggestions shrink your Window .xaml file from 54 to 37 lines (Resources.xaml has 14).