Solved

WPF datagrid column width

Posted on 2015-02-17
2
256 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 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