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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:49:55+00:00 2026-05-24T22:49:55+00:00

I have a DataGrid with 2 templated columns: the first includes a combobox and

  • 0

I have a DataGrid with 2 templated columns:

  • the first includes a combobox and I let it size to fit its content, as this is at most one or two words;

  • the second instead includes a textbox where text might become somewhat long.

So here I set MaxWidth=somevalue to avoid its width expand beyond the datagrid container, I do the same for its MaxHeight, and set text to wrap. Anyway, I’d like the textbox to size its width to fill all the remaining space in the datagrid container: if the user shrinks or enlarges the 2nd column, I’d like the textbox to shrink or enlarge accordingly so that their width stay in synch. Text will wrap, and scrollbars appear as necessary.

Both controls in the grid are bound to a data source in a MVVM scenario. Could anyone give a hint for letting the template textbox width expand/contract with the container column? Here is my sample code:

<DataGrid ...>
  <DataGrid.Columns>
    <!-- 1 -->
    <DataGridTemplateColumn ...>
      <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
          <ComboBox .../>
        </DataTemplate>
      </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>

    <!-- 2: THIS TEXTBOX SHOULD EXPAND/CONTRACT WITH ITS CONTAINER COLUMN -->
    <DataGridTemplateColumn ...>
      <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
          <TextBox TextWrapping="Wrap"
               MinWidth="400" MaxWidth="700"
               MaxHeight="400"
               ScrollViewer.VerticalScrollBarVisibility="Auto" .../>
        </DataTemplate>
      </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
  </DataGrid.Columns>
</DataGrid>
  • 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-24T22:49:57+00:00Added an answer on May 24, 2026 at 10:49 pm

    Set HorizontalAlignment="Stretch" on your TextBox and set your DataGrid’s Column Width="*"

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

Sidebar

Related Questions

I have an asp:DataGrid with templated columns. Here's one of those columns: <asp:TemplateColumn> <ItemTemplate>
I have wpf datagrid, in one of columns, I checkboxes added in it, now
I have a DataGrid with 5 template columns, However when I try and add
I have a WPF toolkit DataGrid as the dropdown in a ComboBox template. <toolkit:DataGrid
I have a DataGrid, populated with objects in an ArrayCollection. After updating one of
I have wpf datagrid with number of template columns. some of them have textbox
Hi I have a datagrid that has a number of datagridtemplate columns that are
I have a WPF Toolkit DataGrid with one DataGridTemplateColumn. I've specified in a grid
I have a wpf toolkit datagrid with a few columns, then inside the row
i have a gridview witch contain 4 databound columns and 2 templated column. in

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.