Articles in this section

How to set Foreground color for Watermark text in SfTextBoxExt?

In SfTextBoxExt, the foreground color of the watermark text can be changed by using the Watermark Template.

XAML

<Input:SfTextBoxExt Name="sftextbox"  AutoCompleteMode="Suggest"  
   AutoCompleteSource="{Binding AutoCompleteSource, Mode=TwoWay}">
     <Input:SfTextBoxExt.WatermarkTemplate>
       <DataTemplate>
            <TextBlock Text="Type S to Start" Foreground="Green"/>
       </DataTemplate>
     </Input:SfTextBoxExt.WatermarkTemplate>
</Input:SfTextBoxExt>

C#

public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            var str = "<DataTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">" +
                 "<TextBlock Text=\"Type S to Start\" Foreground=\"Green\" />" +
            "</DataTemplate>";
            DataTemplate template = (DataTemplate)Windows.UI.Xaml.Markup.XamlReader.Load(str);
            sftextbox.WatermarkTemplate = template;
           Collection c = new Collection();
            this.DataContext = c;            
        }
   public class Collection
        {
            public List<string> AutoCompleteSource
            {
                get
                {
                    return new List<string>() { "Sam", "Sarvan", "Stephen" };
                }
            }
        }
    }

The following screenshot shows the applied foreground color on Watermark text in SfTextBoxExt.

 

Figure 1: Output

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied