Gil
Gil

Reputation: 109

Binding controls from different windows

I have a textbox in a main window which should display text whenever a user selects an item in a listview.

<TextBox Name="txtDoc"  AllowDrop="True" Drop="txtDoc_Drop" Margin="5" />

the listview is actually a user control which is placed in the xaml of the main window:

<v:ClusterDocumentsView x:Name="cdv" DataContext="{Binding Path=ClusterDocumentsViewModel}" Grid.Row="0" Margin="0,10"/>

The MouseDown event in the listview occurs on the user control class, not on the main window. How can I bind the text box in the main window to the listview which is a user control?

Upvotes: 0

Views: 229

Answers (1)

Kent Boogaart
Kent Boogaart

Reputation: 178630

Basically, have the value in question coordinated by your view models if you're doing MVVM. If you're not, you could simply expose another DependencyProperty from your ClusterDocumentsView that your TextBox then binds to.

Upvotes: 1

Related Questions