Reputation: 329
Just an example. The CustomControl has a ViewModel with a property called "Test"
How could I bind the textbox to that specific property? Can you access the siblings ViewModel?
<TextBox Text="{Binding ElementName=myControl, Path=ViewModel.Test}"></TextBox>
<Controls:CustomControl x:Name="myControl" />
Upvotes: 5
Views: 10903
Reputation: 35156
Siblings ViewModel would be in its DataContext try
<TextBox Text="{Binding ElementName=myControl, Path=DataContext.Test}"></TextBox>
<Controls:CustomControl x:Name="myControl" />
Upvotes: 5
Reputation: 81348
May be this is what you required-
<TextBox Text="{Binding Source={x:Static local:VieModel}, Path=Test}"></TextBox>
<Controls:CustomControl x:Name="myControl" />
Don't forgot to add the markup extension to include the namespace where your class Viewmodel exists - xmlns:local="clr-namespace:ViewModel NameSpace"
Upvotes: 0