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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:02:57+00:00 2026-05-10T19:02:57+00:00

This is supposed to be a no brainer but I still can’t figure it

  • 0

This is supposed to be a no brainer but I still can’t figure it out.

In my sample app there’s a button and a textbox in a dockpanel. If the content of the textbox is smaller than the content of the textbox the window is as big as it needs to be to display the content of the button. That’s what I want. But if I put more text into the textbox the window gets wider 🙁

The behavior I want is that the window gets the width according to the buttons content and the textbox wraps its content (or/and shows scrollbars if necessary).

Thank you!

Some sample code:

<Window x:Class='SO1.Window1'     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'     Title='Window1' SizeToContent='Width' FontSize='20'>     <DockPanel>         <Button DockPanel.Dock='Top'>A rather long text</Button>         <TextBlock TextWrapping='Wrap'>Short text</TextBlock>     </DockPanel> </Window> 
  • 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-10T19:02:57+00:00Added an answer on May 10, 2026 at 7:02 pm

    Having tried it, it seems that binding the TextBlock‘s MaxWidth to the ActualWidth of the Button achieves the effect you’re after:

    <Button x:Name='btn' DockPanel.Dock='Top'>Short text</Button> <TextBlock TextWrapping='Wrap'    MaxWidth='{Binding ElementName=btn,Path=ActualWidth}'>A rather long text</TextBlock> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure this out since a while but I can't seem to
I suppose this should be a no brainer for some, but I couldn't find
this supposed to be easy task, but in fact i spent hour to solve
Is this supposed to work? When i use <xs:pattern value=(!red|green|blue)/> everything is fine, but
Im trying to achieve an output like this {status:ok,0:{id:11,title:digg,url:http://www.digg.com}} but instead i am getting
I see this in a lot of game engine code. Is this supposed to
I have a WCF webservice I can connect to it via basicHttp, but not
Isn't this supposed to produce a segfault? When I run the code the output
I have this model at app/models/product.php : class Product extends AppModel { var $hasAndBelongsToMany
My initial attempt looked like this (supposed we want to multiply) __m128 mat[n]; /*

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.