Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to,bind the property of first/second/third Viewmodel to a grid column in a single view.
C#
DataContext="{DynamicResource VMContainer}

C#


C#
public class VMContainer
    {
        public FirstViewModel   VM1 { get; set; }
        public SecondViewModel  VM2 { get; set; }
        public ThirdViewModel  VM3 { get; set; }
    }

If it is a single viewmodel, can do like below.

C#
ItemsSource="{Binding Source={StaticResource VMContainer}}

GridColumn Header="Salary" Binding="{Binding Salary, Mode=TwoWay}"


What I have tried:

Tried like below:

C#
Binding="{Binding VM1.Salary, Mode=TwoWay}"

C#
Binding="{Binding VMContainer.VM1.Salary, Mode=TwoWay}"

How could I explicitly reference each property in the appropriate view model to grid column in view..!
Posted
Updated 11-Oct-16 22:31pm
v3
Comments
Pankaj Nikam 4-Nov-16 4:49am    
Where does the Salary object come from?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900