Search code examples
wpfstylestooltiptogglebutton

WPF ToolTip Style


I have one ToggleButton with ToolTip, content of ToolTip is bind with Text property. Now I need to style my ToolTip within ToggleButton. I know its not allow me apply style within ToggleButton for ToolTip and I don't know how to do it.

Here is what my code looks like:

<ToggleButton
    x:Name="btn"
    Margin="10,0,0,20"
    Style="{StaticResource bubbleStyle}"
    ToolTip="{Binding ElementName=tbText, Path=Text, Mode=TwoWay}" />  

Solution

  • If I understand your question correctly, you want to define a style for ToolTip within your ToggleButton.

    Try this:

    <ToggleButton Content="ON" Grid.Row="1" ToolTip="{Binding ElementName=tbText, Path=Text}">
        <ToggleButton.Resources>
            <Style TargetType="ToolTip" BasedOn="{StaticResource {x:Type ToolTip}}">
                <Setter Property="Background" Value="Red" />
            </Style>
        </ToggleButton.Resources>
    </ToggleButton>