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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:32:29+00:00 2026-05-16T07:32:29+00:00

I have a horizontal StackPanel with an image and another StackPanel. The inner StackPanel

  • 0

I have a horizontal StackPanel with an image and another StackPanel. The inner StackPanel is vertical with two TextBlocks both of which have TextWrapping set to Wrap. However when the text gets wide the inner StackPanel increases in width so that the TextBlocks don’t wrap. The outer StackPanel is staying with the grid layout space it has been given. How can I make the inner StackPanel stay within the bounds of the outer StackPanel?

Here’s the relevant section of XAML:

    <StackPanel Name="_imageAndNameStackPanel"
               Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" 
               Orientation="Horizontal"  Margin="12,12,12,0">
        <Image Name="_applicationImage" Source="{Binding Path=ImageUri}" 
               Stretch="Fill" Height="64" Width="64" HorizontalAlignment="Left"
               VerticalAlignment="Top" Margin="0,0,12,0" />
        <StackPanel Name="_nameStackPanel">
            <TextBlock Name="_nameTextBlock" Text="{Binding Path=AppName}" 
                 FontSize="24" VerticalAlignment="Top" TextWrapping="Wrap"/>
            <TextBlock Name="_subtitleTextBlock" Text="{Binding Path=Subtitle"
                 FontSize="18" VerticalAlignment="Top" Margin="0,6,0,0" 
                 TextWrapping="Wrap"/>
        </StackPanel>
    </StackPanel>
  • 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-05-16T07:32:30+00:00Added an answer on May 16, 2026 at 7:32 am

    You’re probably better off with a DockPanel instead of StackPanel.

    <StackPanel Name="_imageAndNameStackPanel"
               Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" 
               Orientation="Horizontal"  Margin="12,12,12,0">
        <Image Name="_applicationImage" Source="{Binding Path=ImageUri}" 
               Stretch="Fill" Height="64" Width="64" HorizontalAlignment="Left"
               VerticalAlignment="Top" Margin="0,0,12,0" />
        <DockPanel Name="_nameStackPanel">
            <TextBlock Name="_nameTextBlock" Text="{Binding Path=AppName}" 
                 FontSize="24" VerticalAlignment="Top" TextWrapping="Wrap" 
                 DockPanel.Dock="Top" />
            <TextBlock Name="_subtitleTextBlock" Text="{Binding Path=Subtitle"
                 FontSize="18" VerticalAlignment="Top" Margin="0,6,0,0" 
                 TextWrapping="Wrap" DockPanel.Dock="Top"/>
        </DockPanel>
    </StackPanel>
    

    Lately I’m finding that 2 out of 3 times that I start with StackPanel I end up changing it to DockPanel.

    But… are you sure that the outer StackPanel is not expanding beyond the bounds of its grid cell? You might want to make that one a DockPanel as well, with both the Image and the inner DockPanel having DockPanel.Dock="Left".

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

Sidebar

Related Questions

I have a textblock inside a vertical stackpanel inside a horizontal stackpanel (think Facebook
I have wpf user control <StackPanel Orientation=Horizontal> <TextBox Name=txbInterval Text=5/> <Image Name=imgStart Source=Images/start.png/> <Image
I have a ListBox which has StackPanel s holding a TextBlock and an Image
I have a HierarchicalDataTemplate which has some simple Items contained in a horizontal StackPanel.
This is what I have <GridViewColumn Header=Status > <GridViewColumn.CellTemplate> <DataTemplate> <StackPanel Orientation=Horizontal> <Image Source={Binding
I have a horizontal list on which I have placed borders on the li
I have implemented a listbox with buttons as follows <Button.Content> <StackPanel Orientation=Horizontal Width=440 Height=210>
I have a form in which I display a bunch of image. I would
I have a ListBox with a StackPanel that contains an image and label. <ListBox.ItemsPanel>
I have the following ItemTemplate: <ItemsControl ItemsSource={Binding Topics}> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation=Horizontal Margin=10,0> <TextBlock

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.