Is it possible to set image as background to textbox

Usha Patil 31 Reputation points
2020-12-04T14:11:34.217+00:00

Is it possible to set image as background to textbox

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,699 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Rajanikant Hawaldar 91 Reputation points
    2020-12-04T14:18:23.58+00:00

    Yes its possible check below,

    <TextBox.Background>  
        <ImageBrush ImageSource="Rose.jpg" />  
    </TextBox.Background> 
    
    0 comments No comments

  2. DaisyTian-1203 11,616 Reputation points
    2020-12-07T02:53:00.59+00:00

    You can also set the image in the cs code:

            ImageBrush textImageBrush = new ImageBrush();  
            textImageBrush.ImageSource = new BitmapImage(new Uri(@"...\1.jpg", UriKind.RelativeOrAbsolute));  
            textImageBrush.AlignmentX = AlignmentX.Left;  
            textImageBrush.Stretch = Stretch.None;  
            myTextBox.Background = textImageBrush;  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments