Solved

WPF datagrid column width

Posted on 2015-02-17
2
227 Views
Last Modified: 2015-02-17
Hi,

I am using wpf data grid in one of my projects, i am setting the column width from my xaml.cs file

datagrid.columns[0].width = 100;
datagrid.columns[1].width = 200;

Now when i drag the column and increase the column width, check the column width it is still displaying me the old column width i.e. 100 and 200. But it should have given me the new column width as i have dragged the column and increased the width.

Can anyone help me in finding a way out of this.

Thanks,
Rajeeva
0
Comment
Question by:rajeeva_nagaraj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40614350
Is this real code? C# is case sensitive and "columns" does not exist for sure! Have you tried ActualWidth?
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40614614
Hi rajeeva_nagaraj;

Perhaps this may be why it is always the same value. Try using ActualWidth.

From Microsoft Documentation:
The return value of this property is always the same as any value that was set to it. In contrast, the value of the ActualWidth may vary. The layout may have rejected the suggested size for some reason. Also, the layout system itself works asynchronously relative to the property system set of Width and may not have processed that particular sizing property change yet.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question