4

I have an observable collection of objects in my VM. I want to bind to a property of a specific item in the list in a text block, something like this:

Binding="{MyVMCollection[0].Description}"

But this syntax does not work. Is it possible to do what I am after and if so, how?

Thanks!

4

2 回答 2

6

You're missing the Binding keyword and I think you also need to use Path.

Binding="{Binding Path=MyVMCollection[0].Description}"
于 2012-12-10T20:39:34.753 回答
1

对象的类型必须是数组索引通常可以正常工作的类型。我不确定确切的限制,但Type[]如果有疑问,请使用。

例如。如果它是一些奇怪的可枚举类型IOrderedEnumerable<T>(或一些奇怪的 LINQy 类型),那么类似的东西{Binding List[0]}将不起作用。

于 2013-10-26T07:16:18.220 回答