0

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.

2 Answers 2

4
<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>
Sign up to request clarification or add additional context in comments.

8 Comments

but it should open a dialog on hovering mouse which will disappear as i remove mouse over it. and How i will handle it in ViewModel.cs ? Because it has to work MVVM approach
@user234839: It will show a box with the tooltip text. What do you mean by "open a dialog"? And if you are using an MVVM approach opening a tooltip from Viewmodel would be wrong in my eyes. Do you mean you want to bind a string from the viewmodel?
I have to show a child window . Is it possible ? If not then do you know another way to do in silverlight?. I will open a window on mouse hover (Not necessary we use button we can use text box if you want, but mouse hover to it must show a box/window or dialog which on removing the mouse over it will not display any more). Is it possible to display a child window ?
@user234839: I'm not convinced that you really need to show a ChildWindow. This sounds more like "need to display more than just text". Do my edits solve your problem?
but there is no Mvvm approch on this updated part. I mean no binding or anything.
|
1

Try this

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

2 Comments

Thanks bhai but it must show a big box which will conwtain some button and textbox as well
The property ToolTip is only available in WPF.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.