WPF绑定路径= /不工作? [英] WPF Binding Path=/ not working?

查看:201
本文介绍了WPF绑定路径= /不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了我的的DataContext 是这样的:

I've set up my DataContext like this:

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

其中,下载管理器可枚举&LT; D​​ownloadItem&GT; 。然后,我把我的的DataGrid 是这样的:

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

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

所以,它应该列出所有DownloadItems,对不对?所以,我应该能够把我列这样的:

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}"

其中,乌里是属性的 DownloadItem 。但它似乎并不喜欢这样。在可视化的属性编辑器,它不承认乌里是一个有效的属性,所以我猜,我做错了什么。

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:所谓不工作我的意思是没有列出任何项目。我已经添加了一些对DM的构造,所以它不应该是空的。

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.

推荐答案

尝试的ItemsSource ={结合}。它应该是足够的。

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

这篇关于WPF绑定路径= /不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆