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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:27:27+00:00 2026-05-18T10:27:27+00:00

Standard WPF 4 Datagrid. Let’ say I have datagrid 200 pixels wide, and 2

  • 0

Standard WPF 4 Datagrid.

Let’ say I have datagrid 200 pixels wide, and 2 columns. I would like the columns take always entire space, meaning if the user resizes the first column to 50 pixels, the last one would be 150.

Initially I set width 100 pixels for the 1st column, and * for the last one (in XAML).

I thought the problem is with removing the virtual, 3rd column, as explained here:

http://wpf.codeplex.com/Thread/View.aspx?ThreadId=58939

but there is no difference really — still, when resizing the columns, I get some extra space on right — with virtual column, it is a virtual column (white color by default), without it, it is empty space (gray by default).

QUESTION: how to enforce the constraint, that no matter how the user resizes the columns,

sum(columns width)==datagrid width

?

Edits

Yes, I use WPF 4.

WORKAROUND

I marked one of the answers as solution, but actually it is not a solution due to WPF design. It is simply what WPF can do at best, and it is not very good — first of all the option CanUserResize for column means really IsResizeable and this option when turned on contradicts Width set to *. So without some really smart trick you end up with:

  • datagrid which last column in superficially resizable but in fact it is not, and little space on right is shown (i.e. the virtual column is not resizable) — for last column: CanUserResize=true, Width=*

  • datagrid which last column cannot be resized by user and it is shown accordingly, initially no space on right is shown, but it can be shown when user resizes any element of datagrid — for last column: CanUserResize=false, Width=*

So far I can see two problems with WPF datagrid:

  • misleading naming
  • contradiction of features

I am still all ears to how really solve this issue.

  • 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-18T10:27:27+00:00Added an answer on May 18, 2026 at 10:27 am

    Set the width for the data grid to “Auto”. You’re allowing the columns to resize correctly within the grid itself, but you’ve hard-wired the width to 200.

    UPDATE: Base on @micas’s comment, I may have misread. If that’s the case, try using 100 for the left column’s width and 100* for the right column (note the asterisk). This will default the width for the right column to 100 but allow it to resize to fill the grid.

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

Sidebar

Related Questions

I've deconstructed a standard WPF button using Blend and have managed to create a
I have a FlowDocument in a standard WPF application window where I have some
So WPF doesn't support standard sorting or filtering behavior for views of CompositeCollections, so
So standard Agile philosophy would recommend making your domain classes simple POCOs which are
Can standard pointers in .Net do this? Or does one need to resort to
In standard ASP.net applications ASP.net offered some protection from XSS attacks with validateRequest throwing
The standard model has been that OpenGL is for professional apps (CAD) and Direct3D
In standard php or source code based projects we easily keep all of the
Using standard mysql functions is there a way to write a query that will
The standard naming convention in the Java world is to name packages, classes and

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.