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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:22:03+00:00 2026-05-22T02:22:03+00:00

Notice how the textbox expands to the right until it has enough horizontal space

  • 0

Notice how the textbox expands to the right until it has enough horizontal space to fit the content? Well I’d like it to not expand and fit the text with the space it has in the window.

enter image description here

If the windows expands, then the Grid.Column it’s in will expand, but the textbox itself should expand to fit. Simple enough?

Any suggestions? This is my first foray into WPF and so far it’s been pretty sleek.

Edit: Here’s my XAML markup:

<Window x:Class="GameLenseWpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="450" Width="350" MinHeight="450" MinWidth="350">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.15*" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Image Grid.Row="0" Stretch="Fill" Source="Image/topBarBg.png" />
        <StackPanel Orientation="Horizontal" Grid.Row="0">
            <TextBlock Text="Platform" 
                       Foreground="White" 
                       FontFamily="Georgia"
                       FontSize="15" 
                       Margin="10"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"/>
            <ComboBox x:Name="cmbPlatform" 
                      Margin="10"
                      FontFamily="Georgia"
                      FontSize="15"
                      MinHeight="30"
                      MinWidth="140"
                      VerticalAlignment="Center"
                      VerticalContentAlignment="Center" SelectionChanged="cmbPlatform_SelectionChanged">
                <ComboBoxItem>All Platforms</ComboBoxItem>
                <ComboBoxItem>Playstation 3</ComboBoxItem>
                <ComboBoxItem>XBox 360</ComboBoxItem>
                <ComboBoxItem>Wii</ComboBoxItem>
                <ComboBoxItem>PSP</ComboBoxItem>
                <ComboBoxItem>DS</ComboBoxItem>
            </ComboBox>
        </StackPanel>
        <Image x:Name="imgAbout" Grid.Row="0" Source="Image/about.png" 
               Height="16" HorizontalAlignment="Right"
               VerticalAlignment="Center"
               Margin="0 0 10 0"    />
        <ListBox Grid.Row="1" x:Name="lstGames" Background="#343434" Padding="5">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Height="120" Margin="0 10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="90"/>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <Border BorderBrush="#202020" BorderThickness="5" CornerRadius="4" Panel.ZIndex="0">
                            <Image Grid.Row="0" Grid.Column="0" Source="{Binding ImageUrl}" Stretch="Fill"/>                            
                        </Border>

                        <StackPanel Grid.Row="0" Grid.Column="1" Margin="12 0 0 0">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Title:" FontFamily="Arial" Foreground="White"/>
                                <TextBlock Text="{Binding Title}" FontFamily="Arial" Foreground="White" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Release Date:" FontFamily="Arial" Foreground="White" />
                                <TextBlock Text="{Binding ReleaseDate}" FontFamily="Arial" Foreground="White" />
                            </StackPanel>
                            <TextBlock Text="Synopsis" FontFamily="Arial" Foreground="White" />
                            <TextBox Background="#454545" Text="{Binding Synopsis}" MinHeight="76" />
                        </StackPanel>  
                    </Grid>                    
                </DataTemplate>
            </ListBox.ItemTemplate>            
        </ListBox>
    </Grid>
</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. Editorial Team
    Editorial Team
    2026-05-22T02:22:03+00:00Added an answer on May 22, 2026 at 2:22 am

    To get a TextBox to wrap inside a ListBox you can make the following changes:

    1. Set the content of the listbox equal to the width of the listbox using: HorizontalContentAlignment=”Stretch”.
    2. Disable the horizontal scrollbar of the listbox to prevent listbox from getting the desired size of the controls and preventing the word wrap in your textbox.
    3. Set TextWrapping=”Wrap” in the TextBox

    Here is the XAML:

    <ListBox Grid.Row="1" x:Name="lstGames" Background="#343434" Padding="5" 
             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
             HorizontalContentAlignment="Stretch" >
    </ListBox>
    
    <TextBox Text="{Binding Synopsis}" MinHeight="76" TextWrapping="Wrap" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Notice in the bottom right hand corner of this page it has the SVN
I notice that at some websites like http://academia.edu/ , the signup form has some
Notice how for every image that google indexes it has a small thumbnail .
I notice that StackOverflow has a views count for each question and that these
I've got a simple winform. In it has a single TextBox control. In that,
There's a TextBox that I wanna allow users to just enter numbers & not
I pick this date from a textbox and i would like to format to
I'd like to create template for string, that will include label, textbox with watermark
Notice these two RedHat Linux system configuration settings: $ getconf GNU_LIBC_VERSION glibc 2.3.4 $
Notice how the default domain for stackoverflow is http://stackoverflow.com and if you try to

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.