Solved

WPF datagrid column width

Posted on 2015-02-17
2
187 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
2 Comments
 
LVL 69

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 62

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now