Ali Raza
Ali Raza

Reputation: 1131

how to apply text watermark to text box in xaml (windows 8 metrro app)

I am workng on windows 8 app getting problem to use text watermark to text box, can anybody help me to find out how we can apply water mark init .

below is the code of my text box.

<TextBox x:Name="txtUserName" Width="351" Height="45" BorderBrush="Gray" BorderThickness="2" Background="{x:Null}"/>

Upvotes: 0

Views: 3063

Answers (4)

Rahul Sonone
Rahul Sonone

Reputation: 2745

Use

<TextBox Width="250" Name="_txtBox" PlaceholderText="Please enter CS#"/>

enter image description here

Upvotes: 6

Farhan Ghumra
Farhan Ghumra

Reputation: 15296

If you don't want to rely on 3rd party SDKs, you can create your own. Check out these tutorials.

Create Your First WinRT WatermarkTextBox Control

Watermark TextBox in Windows Store apps

WaterMarkTextbox Control in Windows Store Application Using XAML

Upvotes: 0

Luke
Luke

Reputation: 560

There's no way to do it without using a third-party library or overriding the text box and creating your own "Watermark Text Box" class. You just listen for the got/lost focus events and display your text appropriately.

Upvotes: 0

loop
loop

Reputation: 9242

you can use Callisto toolkit for windows 8 it has watermark textbox control. you can install it from nuget package manager. use this namespace in your page..

xmlns:CallistoControls="using:Callisto.Controls"

use the control like this.

 <CallistoControls:WatermarkTextBox Watermark="Type to message"  HorizontalAlignment="Stretch" TextWrapping="Wrap" AcceptsReturn="True" MaxHeight="100"    Padding="5,5,20,30" />

there are other useful controls too. hope this helps you

Upvotes: 2

Related Questions