Reputation: 1131
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
Reputation: 2745
Use
<TextBox Width="250" Name="_txtBox" PlaceholderText="Please enter CS#"/>
Upvotes: 6
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
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
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