Solved

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

Posted on 2014-02-10
1
526 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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

6 Experts available now in Live!

Get 1:1 Help Now