0

I'm fresh new to WPF, and I've been trying to populate a DataGrid, but it shows no values...

As you can see: http://i.epvpimg.com/EJ0Bh.png

Code:

List<FileI> files = new List<FileI>();
foreach (string file in Directory.GetFiles("profileSettings"))
{
    files.Add(new FilI( { fileName = file, fileSize = new FileInfo(file).Length }));
}

dgFilesToExtract.ItemsSource = files;

I checked the folder, there are 2 files, and I placed a BP before the ItemsSource property is set, and the list has items.

What am I doing wrong?

Thanks in advance

Rodrigo Silva
  • 432
  • 1
  • 6
  • 18
  • 3
    Read the [editing help](http://stackoverflow.com/editing-help) and post your code here. – H.B. Sep 09 '13 at 18:33

4 Answers4

2

Your file class only contains fields but you can only bind to properties. Read the documentation.

H.B.
  • 166,899
  • 29
  • 327
  • 400
1

In your File class define properties over the variables and set AutogenerateColumns = true on your datagrid

Nitin
  • 18,344
  • 2
  • 36
  • 53
0

It looks like you are setting the ItemsSource property of the grid in code AND binding it in the XAML. Try removing the binding statement in the XAML.

LeftyCoder
  • 432
  • 1
  • 5
  • 10
  • The XAML value is irrelevant to the problem as it gets replaced on click. Would remove it nonetheless because it of course serves no purpose. – H.B. Sep 09 '13 at 18:37
  • You are correct, I didn't notice that it was being set inside code on a button click. – LeftyCoder Sep 09 '13 at 18:42
0

About the Blurry Font problem. There are lots of topics on this take a look at this one

Community
  • 1
  • 1
Jordy van Eijk
  • 2,718
  • 2
  • 19
  • 37