wpf在用户控件中如何把其中控件的Foreground绑定到UserControl的Foreground?
2个回答
展开全部
假设你的UserControl类型为YourNamespace.MyUserControl
则在xaml中
<UserControl .......
xmlns:local="clr-namespace:YourNameSpace">
<TextBlock Foreground="{Binding RelativeSource={RelativeSource AncestorType=local:MyUserControl}, Path=Foreground}" />
</UserControl>
则在xaml中
<UserControl .......
xmlns:local="clr-namespace:YourNameSpace">
<TextBlock Foreground="{Binding RelativeSource={RelativeSource AncestorType=local:MyUserControl}, Path=Foreground}" />
</UserControl>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询