I am working on an application in C# using the .NET Framework 3.5. I have a TextBox on one of my forms that is bound to the "ID" property of the DataContext of the form, like so:
<TextBox x:Name="txtID"
Grid.Row="0" Grid.Column="1"
Margin="2" MinWidth="200" VerticalAlignment="Top"
Style="{StaticResource validationToolTip}"
>
<TextBox.Text>
<Binding Path="ID" UpdateSourceTrigger="PropertyChanged"
ValidatesOnDataErrors="true">
<Binding.ValidationRules>
<ui:RequiredFieldValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
I would like the TextBox to display some helper text ("[Leave blank to auto-generate.]") when the ID property is empty and the TextBox does not have input focus. I am considering styling this text differently (italicize) to distinguish it from a user-typed ID. Since the TextBox.Text property is bound to the ID property, however, I want to make sure that my solution doesn't cause the ID property to be set to the value of my helper string. How should I go about implementing this behavior?