Question

I am c# silverlight(5) beginner and not a bit know about how to make tool tip. In fact i couldnt find any option in toolbox for tool tip.

What i have to do is to show a tooltip when mouse hover a button. Suppose if i have button like this :

<Button Content="{Binding Path=Id}"
        Command="{Binding DataContext.ShowPopupCommand,
                   RelativeSource={RelativeSource AncestorType=data:DataGrid}}"/>

Now how to create a ToolTip on this button in ViewModel.cs class ?

Could someone please give me guidance on how to create ToolTip in c# silverlight application using MVVM approach. Any piece of code for help is really appreciated. Would be a great help. Thanks.

Was it helpful?

Solution

<Button
    ToolTipService.ToolTip="ToolTip based on the mouse."
    ToolTipService.Placement="Mouse"/>

If you need to display any FrameworkElements (and not just text) you can set the tooltip like this:

<Button>
    <ToolTipService.ToolTip>
        <Border Background="Pink">
            <StackPanel>
                <Image .../>
                <TextBlock .../>
            </StackPanel>
        </Border>
    </ToolTipService.ToolTip>
</Button>

OTHER TIPS

Try this

<Button Content="{Binding Path=Id}"
        Command="{Binding DataContext.ShowPopupCommand,
            RelativeSource={RelativeSource AncestorType=data:DataGrid}}"
        ToolTip="{Binding SomeProperty}"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top