Jacob Saylor
Jacob Saylor

Reputation: 2381

WPF change a tooltip background in c# code

I know how to change the tooltip in the xaml side of things, but does anybody know a great solution to do this in C#?

Upvotes: 2

Views: 3352

Answers (1)

Software.Developer
Software.Developer

Reputation: 999

Say you have a button like this:

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

you can change it like this:

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

Upvotes: 5

Related Questions