开发者

Databinding in the same Control on 2 different DataContext

开发者 https://www.devze.com 2023-02-11 18:32 出处:网络
In Silverlight I\'ve a page with some controls and a listbox. I\'m using MVVM and the dataContext of the listbox is defined like this. In my model I have a property ProductCommand and this ProductCom

In Silverlight I've a page with some controls and a listbox.

I'm using MVVM and the dataContext of the listbox is defined like this. In my model I have a property ProductCommand and this ProductCommand object contains a list of product named Products.

My listbox is in a grid with the datacontext defined as the Pro开发者_Python百科ductCommand property. and the databinding for the listbox is set to the Products (Binding="{Product, Mode=twoWay}").

In my model class I also have a selectedProduct property, and I want to bound it to the SelectedItem property of the listbox.

How can I do that?


I have had similar problems I found this blog article by Dan Wahlin on a Data Context Proxy very helpful.

Of course in Silverlight 5 ancestor binding will also provide you a means to solve this issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号