开发者

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>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜