Friday, 15 August 2014

SilverLight - MVVM binding viewmodel property to datagrid column -


itemprop = "text">

In my Silverlight application, I have a view model called 'vmProperty' and there is a list called 'dgSource'.

I bind my dgSource to the datagrid as itemgrowth, on which each datagrid row's datacentest varies in each item dgSource. One of the columns, called a checkbox column, is required to bind to vmProperty, but when the viewload is no longer the datacontext of the row, I can not use this property.

How do I get this problem? If the question is not clear, please tell me and I will post a sample. Thanks in advance.

Assuming your ViewModel is assigned as LayoutRoot's DataContext, this function IsChecked = "{Binding DataContext.vmProperty, ElementName = LayoutRoot}"

Of course this does not work, eventually a template is repeated and therefore the "layout" is not present in the no-nonsense where the binding is actually used.

This is an easy model, which is to change the model. Expose the expected value on the objects available in DGSource or expose a parent property which goes back to ViewModel


No comments:

Post a Comment