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

Ask A Question

Stats

  • Questions 58k
  • Answers 58k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer One suggestion I got elsewhere was to create a separate… May 11, 2026 at 8:51 am
  • added an answer OK, I emerge from hiding... I used the following program… May 11, 2026 at 8:50 am
  • added an answer DECLARE @BusHourStart DATETIME, @BusHourEnd DATETIME SELECT @BusHourStart = '08:30:00', @BusHourEnd… May 11, 2026 at 8:50 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Explore

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

Footer

Related Questions

No related questions found

© 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.