Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

WPF datagrid column width

Posted on 2015-02-17
2
Medium Priority
?
309 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 64

Accepted Solution

by:
Fernando Soto earned 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

721 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