I have the following code behind:
public void TextBox_GotFocus(object sender, RoutedEventArgs e)
{
TextBox tb = (TextBox)sender;
tb.Text = string.Empty;
tb.GotFocus -= TextBox_GotFocus;
}
My XAML is as follows:
<TextBox x:Name="studyNameBox" Height="20" Margin="30,69,30,0" TextWrapping="Wrap"
Text="Study Name" VerticalAlignment="Top" FontSize="13.333" AllowDrop="False"
GotFocus="TextBox_GotFocus"/>
<TextBox x:Name="studyFacilNameBox" Height="20" Margin="30,101,30,0"
TextWrapping="Wrap" Text="Facilitator Name" VerticalAlignment="Top" FontSize="13.333"
GotFocus="TextBox_GotFocus"/>
<TextBox x:Name="studyNotesBox" Margin="30,132.334,30,97" TextWrapping="Wrap"
Text="Notes" FontSize="13.333" GotFocus="TextBox_GotFocus"/>
On clicking in the first box (studyNameBox) the default text disappears however it does not work for the other two boxes (studyFacilNameBox/studyNotesBox).
Original code from: Remove text after clicking in the textbox
How should I modify this to get all 3 boxes to clear the default text on getting the focus?
Many thanks.