Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8190411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:38:04+00:00 2026-06-07T03:38:04+00:00

I want to make a TextBox surrounded with a glowing border. The TextBox should

  • 0

I want to make a TextBox surrounded with a glowing border.

The TextBox should be as large as it needs to be in order to contain all the text within. But no larger. And the Border should then surround the text.

I use a 3×3 Grid to make the Border centered in the middle of the container. Centering works fine as long as the text is short enough. But when you enter a big long text, the ViewBox will not actually scale the TextBox down in size.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Viewbox Stretch="Uniform" Grid.Row="1" Grid.Column="1" >
        <Border BorderBrush="#bab98b" BorderThickness="7" CornerRadius="15" VerticalAlignment="Center" HorizontalAlignment="Center" Background="Black">
            <TextBox Name="WaitMessage" Text="A Message" HorizontalAlignment="Center" Foreground="White" Background="Black" Padding="20" FontSize="60" Width="Auto"/>
        </Border>
    </Viewbox>
</Grid>

I thought the Viewbox was supposed to scale the content to fit within the dimensions available according to the parent container. But what happens is that if I enter a text that is very long, it will clip at the end.

In short: I want the text to uniformly shrink to available size, but never grow beyond what’s needed.

Can someone explain what I’m doing wrong?

EDIT: Ok, If I Put in 10* as Width and Height of the middle column and row the text will always stay inside the border.
The problem is then that the ViewBox will make the text grow, when it’s only a small text.
I can’t use maxHeight for this purpose I think, because I just never want it to enlarge the text.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:38:12+00:00Added an answer on June 7, 2026 at 3:38 am

    Use Viewbox.StretchDirection Property. StretchDirection.DownOnly will do what you want.

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="10*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="10*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
    
        <Viewbox Grid.Row="1" Grid.Column="1"
                 Stretch="Uniform" StretchDirection="DownOnly">
            <TextBox Text="A Message" FontSize="60" />
        </Viewbox>
    </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to make empty textbox checking for android. i tried try catch but
I want to make a WPF TextBox have a DarkBlue border and thickness equal
I want to make a TextBox's Text display like a PasswordBox's Text. Is there
I want to make my textbox height increases as the user inputs more text
I want to make the textbox allow only three digits and three decimals.For example
Hi I want to make my textbox's width longer. The view that is generated,
i want to make a text box like stackoverflow have for the tag at
I am trying to make some project in which i want a text box
I want to make a simple style for the textbox. I want to retain
I'm want to make website have a textbox and a save button. When you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.