Mega Code Archive

 
Categories / VB.Net / WPF
 

Specify a Default Value for a Binding

<Window x:Class="WpfApplication1.Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"      Title="WPF" Height="120" Width="300">     <Grid>         <Grid.ColumnDefinitions>             <ColumnDefinition Width="60"/>             <ColumnDefinition Width="*"/>         </Grid.ColumnDefinitions>         <Grid.RowDefinitions>             <RowDefinition Height="28"/>             <RowDefinition Height="28"/>             <RowDefinition Height="28"/>         </Grid.RowDefinitions>         <TextBlock Margin="4" Text="First Name" VerticalAlignment="Center"/>         <TextBox Margin="4" Text="{Binding Path=FirstName, FallbackValue=First name goes here}"                  FontStyle="Italic" Grid.Column="1"/>                  <TextBlock Margin="4" Text="Last Name" Grid.Row="1" VerticalAlignment="Center"/>         <TextBox Margin="4" Text="{Binding Path=LastName, FallbackValue=Second name goes here}"                  FontStyle="Italic" Grid.Column="1" Grid.Row="1"/>                  <TextBlock Margin="4" Text="Age" Grid.Row="2" VerticalAlignment="Center"/>         <TextBox Margin="4" Text="{Binding Path=Age, FallbackValue=Age goes here}"                  FontStyle="Italic" Grid.Column="1" Grid.Row="2"/>     </Grid> </Window>