Home > DeveloperSection > Forums > How to create image water mark in textbox using wpf?
john rob

Total Post:108

Points:756
Posted on    August-08-2013 7:36 AM

 WPF WPF 
Ratings:


 1 Reply(s)
 936  View(s)
Rate this:

How to create image water mark in textbox using wpf?



shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Points:735
Posted on    August-09-2013 6:40 AM

Hi !

You can set the background image in textbox and write the below code in textbox text change event:-

private void txtSearch_TextChanged(object sender, TextChangedEventArgs e)

        {

            if (txtSearch.Text != "")

            {

                this.txtSearch.Background = null;

            }

            else

            {

                ImageBrush mybrush = new ImageBrush();

                mybrush.ImageSource = new BitmapImage(new Uri("Image Path"));

                this.txtSearch.Background = mybrush;

            }

        }

thanks


Don't want to miss updates? Please click the below button!

Follow MindStick