Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Binding Path=/ not working?

I've set up my DataContext like this:

<Window.DataContext>
    <c:DownloadManager />
</Window.DataContext>

Where DownloadManager is Enumerable<DownloadItem>. Then I set my DataGrid like this:

<DataGrid Name="dataGrid1" ItemsSource="{Binding Path=/}" ...

So that it should list all the DownloadItems, right? So I should be able to set my columns like:

<DataGridTextColumn Binding="{Binding Path=Uri, Mode=OneWay}"

Where Uri is a property of the DownloadItem. But it doesn't seem to like this. In the visual property editor, it doesn't recognize Uri is a valid property, so I'm guessing I'm doing something wrong.

It was working before, when I had the data grid binding to Values, but then I took that enumerable out of the DownloadManager and made itself enumerable. How do I fix this?

PS: By "doesn't work" I mean it doesn't list any items. I've added some to the constructor of the DM, so it shouldn't be empty.

like image 547
mpen Avatar asked Dec 12 '22 22:12

mpen


1 Answers

Try ItemsSource="{Binding}". It should be enough.

like image 100
Danko Durbić Avatar answered Dec 16 '22 16:12

Danko Durbić