MVVM binding viewmodel property child to viewmodel property?

I'd flatten the Model in a customer ViewModel.

I'd flatten the Model in a customer ViewModel: class CustomerViewModel : INotifyPropertyChanged { public string OrgName { get; } public string FirstName {get; } public string LastName { get; } } Then the owning ViewModel returns the collection of Customers: public class StoreViewModel : INotifyPropertyChanged { public ObservableCollection Customers { get; } } Bind the ListBox to the OrgName property on the CustomerViewModel.

I would employ a MultiBinding and a MultiValueConverter for this, this is sadly not possible if you are restricted to Silverlight as the tags suggest though...

I agree with Ritch that you should flatten the model, but if you really don't want to do that, you could use an IValueConverter. In the binding for where you want the name to be displayed, if you set Organizations to be the datacontext of another control, you could do element-to-element binding and pass the other control's datacontext in the binding, and in the ConverterParameter pass the OrganizationId, then in the Converter code use a little LINQ and return the Name you want.

Bind the Listbox to a Linq query exposed from your ViewModel. Public IEnumerable ItemsView { get { return { from customer in this. Customers from org in this.

Organisations where customer. OrganisationId=org. OrganisationId select new { FirstName=customer.

FirstName, LastName=customer. LastName, OrganisationName=org. OrganisationName} }; } Then just bind the listbox in Ritch's answer to this.PS.

I'm writing this on my phone so the code may not be perfect.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions