简体   繁体   English

绑定DataContex。[0]时引发异常?

[英]Throws exception when Bind DataContex.[0]?

My Datacontext is a ObsevableCollection , 我的数据Datacontext是一个ObsevableCollection

I need to bind it with a Value <double> property 我需要将其与Value <double>属性绑定

The below binding not works in my case, (as it a property of dependency object within class of type ObervableCollection<T>) 以下绑定在我的情况下不起作用(因为它是ObervableCollection<T>)类型的类中依赖项对象的属性ObervableCollection<T>)

 Value="{Binding [0]}"

So i need to bind something like this 所以我需要绑定这样的东西

Value="{Binding DataContext.[0], ElementName=grid}"

But it throws exception 但它引发异常

WinRT information: Failed to assign to property 'Windows.UI.Xaml.Data.Binding.Path' WinRT信息:无法分配给属性“ Windows.UI.Xaml.Data.Binding.Path”

How can i resolve this? 我该如何解决?

Thanks in advance JoyRex 在此先感谢JoyRex

给它

Value="{Binding DataContext[0], ElementName=grid}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM