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.
LVL 1
chuang4630Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

apeterCommented:
Your datacontext object is "MyServerView"  which you are going to bind.

In the xaml you give the path while binding { MyServerType.ServerName } to bind to a label or textbox control.
0
chuang4630Author Commented:
You have to use either Parent or Level and relativePath to get this work

        <TextBlock x:Uid="tbkRequired" Name="tbkRequired" HorizontalAlignment="Left" VerticalAlignment="Top"  Margin="570,10,0,0" TextWrapping="NoWrap"  
                    Text="!"
                    Visibility="{Binding Path=RequiredFieldVisibility}"                  
                    FontWeight="Bold" FontSize="16" Foreground="Red"                    
                    >
            <TextBlock.ToolTip >
                <ToolTip DataContext="{Binding Path=PlacementTarget.Parent.Parent, RelativeSource={x:Static RelativeSource.Self}}">
                    <Grid Height="20" VerticalAlignment="Center" HorizontalAlignment="Center">
                        <Border BorderThickness="0" >
                            <TextBlock x:Name="rx" Height="20" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="10" Foreground="Red"
                            Text="{Binding Path=RequiredMessage}" />                                
                        </Border>
                    </Grid>
                </ToolTip>
            </TextBlock.ToolTip>
        </TextBlock>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chuang4630Author Commented:
I have figured it out.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.