How to set Watermark TextBox Text property in code (MahApps)

<TextBox Name="mytextBox" Controls:TextBoxHelper.Watermark="User" Controls:TextBoxHelper.ClearTextButton="True" /> 

I have a ComboBox , and each index I want to modify this Watermark accordingly. Is it possible to change this Property through the code behind?

+4
source share
1 answer

If mytextBox not inside a template or other mytextBox , and you can access it by name in code, you can use the static TextBoxHelper method

 TextBoxHelper.SetWatermark(mytextBox, "New Value"); 

or install it directly

 mytextBox.SetValue(TextBoxHelper.WatermarkProperty, "New Value"); 
+5
source

All Articles