Databinding in style to property on parent window
Is it possible to declare a style that sets the fontsize of tooltips to the same size as the parent form? I have tried this...
<Style TargetType="{x:Type ToolTip}">
<Setter Property="FontS开发者_StackOverflow中文版ize" Value="{Binding ElementName=MainWindow, Path=FontSize}"/>
</Style>
...but that doesnt work. Any suggestions?
I found a solution to my problem.
<Style TargetType="{x:Type ToolTip}">
<Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=FontSize}"/>
</Style>
精彩评论