Solved

WPF Binding to DataGrid  (List is Complete; No data in DataGrid)

Posted on 2014-02-10
1
530 Views
Last Modified: 2014-02-11
I am having trouble with what I believe is the binding to a datagrid.  When I step-through the code, I can see that as the while executes, each row is calculated correctly; that the data is there, but it just doesn't show-up in the datagrid.  I am getting a datagrid with a single empty column (when there should be three columns in this snippet example, with data filling a number of rows).

Does what I have shown provide enough information for someone to right my wrong?
Is there an issue with using the ItemsSource property of DataGrid?  As is seen below, AutoGenerateColumns is set to False.

* * * BEGIN C# SNIPPET * * *

private void RunApp()
{
     List<Result> RowResults = new List<Result>();
     int a = 0;
     int b = 0;
     int c = 0;
     . . .
     while (true)
     {
        . . .
        RowResults.Add(new Result() { A = a, B = b, C = c });
     }
dataGrid1.ItemsSource = RowResults;

* * * END C# SNIPPET * * *

Could there be something incorrect with my xaml; a property or reference perhaps?
Here is the DataGrid object:

<DataGrid Name="dataGrid1" AutoGenerateColumns="False"  Width="400" Height="300" HorizontalAlignment="Left" Margin="400,80,0,0" VerticalAlignment="Top" >

Thank you in advance!
0
Comment
Question by:Wizard_Microsystems
1 Comment
 

Accepted Solution

by:
Wizard_Microsystems earned 0 total points
ID: 39851901
Update:  I found a work-around to the binding issue, but it is not the ultimate solution I am looking for.  I looked at my own question and changed the AutoGenerateColumns to True for kicks.  This resulted in proper data and rows in my DataGrid (Yes, .NET 4.0, not .NET 4.5's DataGridView).  However, what I ultimately need is to title my headers appropriately and format the data in the rows.  For that, I believe I'll need manual control of the columns for which a question on that topic is outside of the scope of this one; it's a WPF question.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
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…

863 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

18 Experts available now in Live!

Get 1:1 Help Now