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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:54:29+00:00 2026-05-27T23:54:29+00:00

Consider the following User Control, a somewhat simplified version of my conversation control. I’m

  • 0

Consider the following User Control, a somewhat simplified version of my conversation control. I’m having troubles fixing the width of the text block control (that contains the content of the conversation) to the with of the container control.
What I get is a TextBlock control which doesn’t wrap.

If I hard set the width of the TextBlock control, or the containing DockPanel (e.g. replace the DockPanel with the one in comment) everything is better, although I’ll have to also add a converter to subtract the margin.

I’ve seen many similar question, including in this site, but no definite answer. The {Binding} to the ActualWidth of the parent element seems awkward to me.

<UserControl 
    x:Class="Bar.View.test"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="240"
    >
    <UserControl.Resources>
        <XmlDataProvider x:Key="Conversation" XPath="Discussion">
            <x:XData>
                <Discussion xmlns="">
                    <msg speaker="Mark" picture="http://graph.facebook.com/4/picture?type=small">Hello</msg>
                    <msg speaker="Uri" picture="http://graph.facebook.com/526439429/picture?type=normal">Good Morning</msg>
                    <msg speaker="Mark" picture="http://graph.facebook.com/4/picture?type=small">The quick brown fox jumps over the lazy dog</msg>
                </Discussion>
            </x:XData>
        </XmlDataProvider>
    </UserControl.Resources>

    <ListBox x:Name="lb"
        ItemsSource="{Binding Source={StaticResource Conversation},XPath=*}"
        HorizontalContentAlignment="Stretch"
        >

        <ListBox.ItemTemplate>
            <DataTemplate>
                <!-- <DockPanel LastChildFill="True" Width="{Binding ElementName=lb,Path=ActualWidth}"> -->
                <DockPanel LastChildFill="True">
                    <StackPanel DockPanel.Dock="Left" Orientation="Vertical" Width="40" Margin="2">
                        <Image Source="{Binding XPath=@picture}" />
                        <TextBlock Text="{Binding XPath=@speaker}" FontSize="8"/>
                    </StackPanel>

                    <Border BorderThickness="1" BorderBrush="Blue" CornerRadius="8" Padding="3" Margin="2" >
                        <TextBlock Text="{Binding XPath=.}" TextWrapping="Wrap" />
                    </Border>

                </DockPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

</UserControl>
  • 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-27T23:54:30+00:00Added an answer on May 27, 2026 at 11:54 pm

    I’ve created a repro with your code and in the listbox the horizontal scrollbar is visible that’s why your TextBox doesn’t warp because the listbox’s ScrollViewer allows it to expand infinitely.

    Try to set ScrollViewer.HorizontalScrollBarVisibility="Disabled" on the ListBox and it will wrap the text corrently.

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

Sidebar

Related Questions

Consider following scenario: I have RESTful URL /articles that returns list of articles user
Consider the following use case 1. User selects a product to purchase on seller's
Let's consider following, simplified example: We have 2 tabs withing <rich:tabPanel switchType=ajax> , each
Consider following tables in MySQL database: entries: creator_id INT entry TEXT is_expired BOOL other:
Consider the following file: -rw-r--r-- 1 user user 470886479 2009-12-15 08:26 the_known_universe.png How would
Consider the following sequence of events: A view v_Foo is defined A user-defined function
Consider the following example: as part of configuration for my program the user supplies
Consider the following scanning procedure in a typical document handling webapp: The user scans
Consider the following code in VB9: Dim text = Line1<br/>Line2 Dim markup = <span><%=
Please consider the following simplified example: #include boost/shared_ptr.hpp #include boost/smart_ptr/enable_shared_from_this.hpp using namespace boost; class

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.