Binding to an ancestor in WPF

后端 未结 1 1282
天涯浪人
天涯浪人 2020-12-05 09:53

I have a window in one assembly that has a TextBlock control that I want to bind to the value of a Property of a class that is the property of the DataContext of that window

相关标签:
1条回答
  • 2020-12-05 10:24

    the following should work :

    <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
                                                             AncestorType={x:Type Window}},
                                                             Path=DataContext.Client.Name}" />
    
    0 讨论(0)
提交回复
热议问题