Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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!
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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