Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to assign Watermark property to a TextBox's Text in code behind (MahApps)

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

I have ComboBox and each index i want to change this Watermark accordingly. Is it possible to change this Property via code behind ?

like image 990
berry wer Avatar asked Aug 01 '15 19:08

berry wer


1 Answers

If mytextBox is not inside template or different name scope and you can access it by name in the code you can either use static method of TextBoxHelper

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

or set it directly

mytextBox.SetValue(TextBoxHelper.WatermarkProperty, "New Value");
like image 104
dkozl Avatar answered Oct 06 '22 01:10

dkozl