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

  • Home
  • SEARCH
  • 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 9189521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:15:20+00:00 2026-06-17T20:15:20+00:00

I have a textbox inside a StackPanel and the TextBox is set to AcceptsReturn

  • 0

I have a textbox inside a StackPanel and the TextBox is set to AcceptsReturn, so when you press the Enter/Return key the textbox will become bigger in height.

The problem I’m having is that I don’t know how to make the surrounding StackPanel change in height along with the textbox. So when the textbox changes, so should the StackPanel.

How can we do this?

    <GridView x:Name="texties" Grid.Row="1" Margin="120, 0, 0, 0" ItemsSource="{Binding Something, Mode=TwoWay}" SelectionMode="Multiple">
        <GridView.ItemTemplate>
            <DataTemplate>
                <StackPanel Margin="10" Orientation="Vertical" Width="210" >
                    <StackPanel.ChildrenTransitions>
                        <TransitionCollection>
                            <AddDeleteThemeTransition/>
                        </TransitionCollection>
                    </StackPanel.ChildrenTransitions>
                    <TextBlock Text="{Binding Name, Mode=TwoWay}" FontWeight="Bold" Style="{StaticResource ItemTextStyle}" />
                    <TextBox Text="{Binding Content, Mode=TwoWay}" FontSize="12" Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="0, 0, 0, 0" AcceptsReturn="True" IsSpellCheckEnabled="True" />
                </StackPanel>
            </DataTemplate>
        </GridView.ItemTemplate>
    </GridView>
  • 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-17T20:15:22+00:00Added an answer on June 17, 2026 at 8:15 pm

    Based on your sample you are not setting the GridView.ItemsPanel. The default value of GridView.ItemsPanel is <WrapGrid /> which has a set cell size that cannot be changed. You might be tempted to update to <VariableSizedWrapGrid /> but this control cannot change span values except during render. If what you want is even possible, it will require that you use <StackPanel/> as your GridView.ItemsPanel. However, <StackPanel/> does not wrap natively, so you will either need to locate a wrapping version someone else has made, make your own, or live with it in a single row or column.

    Some developers attempt to change the size of their template based on the height of their <TextBlock />. This is a good idea but a difficult tech to execute. It turns out that the size of a UI Element is not determined until it is rendered and so you have to render it first, and then it is too late. If you want to see how one developer has accomplished this calculation (consider the difficulty of font-family and font-size and margin, etc) look here. Such a calc would allow you to use <VariableSizedWrapGrid />.

    In this sample he is calculating for an ellipse, but it’s ~the same calculation.

    protected override Size MeasureOverride(Size availableSize)
    {
        // just to make the code easier to read
        bool wrapping = this.TextWrapping == TextWrapping.Wrap;
    
    
        Size unboundSize = wrapping ? new Size(availableSize.Width, double.PositiveInfinity) : new Size(double.PositiveInfinity, availableSize.Height);
        string reducedText = this.Text;
    
    
        // set the text and measure it to see if it fits without alteration
        if (string.IsNullOrEmpty(reducedText)) reducedText = string.Empty;
        this.textBlock.Text = reducedText;
        Size textSize = base.MeasureOverride(unboundSize);
    
    
        while (wrapping ? textSize.Height > availableSize.Height : textSize.Width > availableSize.Width)
        {
            int prevLength = reducedText.Length;
    
            if (reducedText.Length > 0)
                reducedText = this.ReduceText(reducedText);    
    
            if (reducedText.Length == prevLength)
                break;
    
            this.textBlock.Text = reducedText + "...";
            textSize = base.MeasureOverride(unboundSize);
        }
    
        return base.MeasureOverride(availableSize);
    }
    

    Best of luck.

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

Sidebar

Related Questions

I have a textbox inside a TemplateField column for a gridview. When I set
I have a TextBox inside an asp.net UpdatePanel that records the number of key
I have a textbox inside the gridview. IF i enter any non-numeric values it
I have a RadioButton and a TextBox inside one StackPanel as shown below: <StackPanel
I have ContentControls like ComboBox and TextBox inside of a Grid or a StackPanel.
I have a textbox inside the anchor tag. And I want to get its
I have: Textbox(Multi-line) Panel Different controls inside panel (buttons,textbox) Scenario: I need to add
I have to add a textbox inside a form that is composed of a
What's the best way to have the following? Name: [Textbox] Inside a div? I
I would like to have direct access to the text inside a textbox on

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.