Solved

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

Posted on 2014-02-10
1
540 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
[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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
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.

636 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