繁体   English   中英

WPF在C#代码中更改工具提示背景

[英]WPF change a tooltip background in c# code

我知道如何在xaml方面更改工具提示,但是没有人知道在C#中实现此目的的绝佳解决方案吗?

假设您有一个像这样的按钮:

    <Button x:Name="btnOne" Content="How to grow big and strong?">
        <Button.ToolTip>
            <ToolTip>
                Eat your veggies
            </ToolTip>
        </Button.ToolTip>
    </Button>

您可以像这样更改它:

    var tip = ToolTipService.GetToolTip(this.btnOne) as ToolTip;
    tip.Background = new SolidColorBrush(Colors.Magenta);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM