开发者

Databinding in style to property on parent window

开发者 https://www.devze.com 2022-12-17 06:33 出处:网络
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...

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

精彩评论

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