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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:05:56+00:00 2026-06-11T16:05:56+00:00

So I have a ListBox that has a DataTemplate which has a Grid which

  • 0

So I have a ListBox that has a DataTemplate which has a Grid which has a RichTextBox.
For some reason when you type into the RichTextBox it puts each character on a separate line. Digging into this, I find out that the ExtentWidth is equal to 10.003. Why? I have no idea. I was hoping someone could explain to me why and give a nice solution to make it stop doing this.

I did notice that if you set a width on the grid’s column, it fixes it, but I don’t want a static width on my grid’s column.

Below is an example of the problem. I am using .Net 4 and VS 2010.

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfApplication1"
    Title="MainWindow" Height="350" Width="525">
<ListBox 
    DockPanel.Dock="Top" 
    x:Name="TestListBox">
    <ListBox.ItemTemplate>
        <DataTemplate DataType="{x:Type local:Test}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBox Grid.Column="0" Grid.Row="0" Text="{Binding Name}" />
                <TextBlock Grid.Column="1" Grid.Row="0" Text="Test" />
                <RichTextBox
                    Grid.Column="1" Grid.Row="1"/>
            </Grid>
        </DataTemplate>
    </ListBox.ItemTemplate>
    <local:Test Name="Test1" />
    <local:Test Name="Test2" />
</ListBox>

using System.Windows;

namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }
}

public class Test
{
    public string Name { get; set; }

    public Test()
    {
    }
}
}
  • 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-11T16:05:57+00:00Added an answer on June 11, 2026 at 4:05 pm

    So I figured out a workaround. If you trade out the ListBox for a DataGrid and use DataGridTemplateColumns with the Width of the TemplateColumn set to "*" then it seems to work.

    <DataGrid
        x:Name="TestDataGrid"
        CanUserReorderColumns="False"
        CanUserResizeColumns="False"
        >
        <DataGrid.Columns >
            <DataGridTemplateColumn Width="*">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <RichTextBox />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    
        <local:Test Name="Test1" />
        <local:Test Name="Test2" />
    </DataGrid>
    

    Note I also set the CanUserResizeColumns to False because if you don’t and they resize them, the ExtentWidth will snap back to 10.

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

Sidebar

Related Questions

I have a listbox that has a datatemplate which contains multiple text boxes. I
I have a ListBox in Silverlight that has a list of items inside. Each
I have a listbox which has couple of items. When double clicked on each
I have a ListBox that each of its items has a button, I set
I have a ListBox that contains a Grid. The Grid has a Label Column,
In Silverlight, I have a Vertical ListBox that has a Horizontal ListBox for each
I have a ListBox that has a custom DataTemplate assigned to it, so that
I currently have a listbox that has its selected item bound to a property
I am new to WPF. I have a ListBox that has its ItemSource set
So I have a form that has a listbox that shows like a ledger.

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.