Home > DeveloperSection > Forums > how to set image in textbox in wpf
Hank Greenberg
Hank Greenberg

Total Post:12

Posted on    July-18-2013 2:59 AM


 1 Reply(s)
 3347  View(s)
Rate this:
HI mindstick!

I Have TextBox In My Application That I Want to Add Image To This , Some Times

Like Microsoft Office Word I am Going To Have Both Text And Image

Is it Possible ?

If It possible How?


shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Posted on    July-18-2013 11:24 PM


From XAML:

<TextBox Name="myTextBox" TextChanged="OnTextBoxTextChanged" Width="200">


    <ImageBrush ImageSource="TextBoxBackground.gif" AlignmentX="Left" Stretch="None" />



From C#

// Create an ImageBrush.

ImageBrush textImageBrush = new ImageBrush();

textImageBrush.ImageSource = new BitmapImage(new Uri(@"TextBoxBackground.gif", UriKind.Relative));

textImageBrush.AlignmentX = AlignmentX.Left;

textImageBrush.Stretch = Stretch.None;

// Use the brush to paint the button's background.

myTextBox.Background = textImageBrush;

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

Follow MindStick