使用FindAncestor查找方式绑定且不需要使用datacontext
原文:
使用FindAncestor查找方式绑定且不需要使用datacontext
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄
<UserControl x:Class="QuJiao.AnimationVideoPlayer"
xmlns:local="clr-namespace:QuJiao">
<TextBlock
Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Stretch"
x:Name="TextBlock1"
Foreground="#999999"
FontFamily="微软雅黑"
FontSize="20"
Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType=local:AnimationVideoPlayer},Path=VolumeText}"
/>
其中[local:AnimationVideoPlayer]即为在此类中查找绑定目标[VolumeText],AncestorLevel=1为搜索第一层
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
更多精彩