how to set image in textbox in wpf

Total Post:12

Points:84

WPF 
WPF
 4372  View(s)
Ratings:
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?

Thanks.

  1. Re: how to set image in textbox in wpf

    Solution!

    From XAML:

    <TextBox Name="myTextBox"
    TextChanged="OnTextBoxTextChanged" Width="200">
      <TextBox.Background>
        <ImageBrush ImageSource="TextBoxBackground.gif" AlignmentX="Left" Stretch="None" />
      </TextBox.Background>
    </TextBox>

    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;

      Modified On Mar-30-2018 05:21:58 AM

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.