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.
精彩评论