Universal Apps – TextBox

Though not specifically for Universal Apps, the TextBox control has been nicely enhanced. In the past, if we wanted a header, we had to add a TextBlock before the TextBox. This meant coordination was required every time the TextBox had to be repositioned. Now the TextBox control includes a Header parameter. If you are not entirely happy with how the Header appears, There is a HeaderTemplate.  Just include

<TextBox.HeaderTemplate><DataTemplate>Text=”Header”</DataTemplate></TextBox.HeaderTemplate>

within the TextBox control. Now you can format it to your hearts content and it will move with the TextBox if it is repositioned.

Another new feature is that you can include a watermark within the TextBox as a placeholder. So if the TextBox is empty, it displays some default  text.  This is handled by the PlaceholderText parameter.

Of course, those that know me know that I like making everything multilingual. These parameters do not disappoint, they also support multilingual text. Just add a x:Uid to the TextBox and include rows in the resource file referencing that Uid. So, if the Uid is Num1, your resource file should include Num1.Header and Num1.PlaceholderText. If you do add the HeaderTemplate, it can use an x:Uid within the TextBox or a different x:Uid within the HeaderTemplate.

No matter how many times I do it, I still need to double check the difference between TextBox and TextBlock.

Enjoy.

John Marshall… Visio MVP       Visio.MVPs.org

Published by johnvisiomvp

The original Visio MVP. I have worked with the Visio team since 1993