Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextBlock Background Property removing stretch

I have a TextBox defined as this:

<TextBox>
    <TextBox.Background>
        <VisualBrush>
            <VisualBrush.Visual>
                <StackPanel>
                    <TextBlock Background="Blue" Opacity="0.5" Text="155"/>
                </StackPanel>
            </VisualBrush.Visual>
        </VisualBrush>
    </TextBox.Background>
</TextBox>

It looks like this:

enter image description here

However, when I remove the Background property, the text stretches like this:

enter image description here

Is there any way to add the background without changing the way the text looks?

like image 649
Duke Cyrillus Avatar asked Apr 18 '26 21:04

Duke Cyrillus


1 Answers

If you use Background="Transparent" it will use the same layout but with no background color. Is that what you're trying to do?

like image 199
John Bowen Avatar answered Apr 20 '26 12:04

John Bowen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!