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 115275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:59:36+00:00 2026-05-11T02:59:36+00:00

So I’m coming at WPF from a HTML perspective. I just want to put

  • 0

So I’m coming at WPF from a HTML perspective.

I just want to put a TextBox on my Window like this:

<Grid>     <TextBox Name='theName' /> </Grid> 

Turns out that the TextBox is then HUGE, covers the whole window. (!)

Ok, that’s not what I want, but I don’t want to define the EXACT size either since I know Height and Width should be flexible, so I try:

<TextBox Name='theName' Width='Auto' Height='Auto'/> 

Same thing. So I try:

<TextBox Name='theName'      HorizontalAlignment='Stretch'      VerticalAlignment='Stretch'/> 

Same thing. So I just hard code the sizes:

<TextBox Name='theName' Width='100' Height='20'/> 

Which I know is not a good programming practice in WPF.

So, what how do you tell TextBox to ‘display default sizes for the font size being used’?

  • 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. 2026-05-11T02:59:37+00:00Added an answer on May 11, 2026 at 2:59 am

    You can take Bryan’s example even a bit further. By specifying a specific alignment that isn’t stretch and further constrain the TextBox so that it won’t expand beyond a certain size. eg:

    <Grid x:Name='LayoutRoot'>         <TextBox HorizontalAlignment='Left' VerticalAlignment='Top' Text='TextBox' TextWrapping='Wrap'          MinWidth='15' MinHeight='20' MaxWidth='500' MaxHeight='50'/> </Grid> 

    You can take it even further by setting up rows/columns inside the Grid and constraining them in various fashions. As you’re coming from an HTML background, think of it like using a table to control layout. Remember that you can also nest other container objects (i.e. StackPanels, WrapPanels, other Grids, etc…).

    The challenge with XAML and the WPF/Silverlight controls is that they a very flexible, so you’ve got to get a handle on all the options and how they affect layout.

    Good luck. I’m going through this exact same thing now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.