开发者

Binding controls from different windows

开发者 https://www.devze.com 2023-03-12 05:38 出处:网络
I have a textbox in a main window which should display text whenever a user selects an item in a listview.

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开发者_Python百科 is a user control?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消