chuang4630
asked on
How to bind the property in nested user control in WPF MVVM?
I have implemented a basic user control: UCComboTextBox. It consists three fields:
1. Title (Textblock)
2. TextValue (Textbox)
3. Desc (Textblock)
Then I implemented a user control MyServerView containing two basic user controls plus a checkbox chkDefault.
I have a View Model MyServerViewModel, corresponding MyServerView. MyServerView contains two properties:
1. Server of MyServerType
2. ServerList of List<MyServerType>
MyServerType contains three properties:
1. ServerName (string)
2. ServerLocation (string)
3. IsDefaultServer (bool)
The question becomes:
1. Do I need to create view model for the basic user control UCComboTextBox?
2. How do I bind the Text Value (in MyServerView) to Server.ServerName, Server,ServerLocation and Server.IsDefaultServer?
Thanks a lot in advance.
1. Title (Textblock)
2. TextValue (Textbox)
3. Desc (Textblock)
Then I implemented a user control MyServerView containing two basic user controls plus a checkbox chkDefault.
I have a View Model MyServerViewModel, corresponding MyServerView. MyServerView contains two properties:
1. Server of MyServerType
2. ServerList of List<MyServerType>
MyServerType contains three properties:
1. ServerName (string)
2. ServerLocation (string)
3. IsDefaultServer (bool)
The question becomes:
1. Do I need to create view model for the basic user control UCComboTextBox?
2. How do I bind the Text Value (in MyServerView) to Server.ServerName, Server,ServerLocation and Server.IsDefaultServer?
Thanks a lot in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have figured it out.
In the xaml you give the path while binding { MyServerType.ServerName } to bind to a label or textbox control.