tags:

views:

48

answers:

2

Hi I would like to create a listbox, with a details pop-up/tooltip kind of window. Scenario is as following:

  • List of items
  • Show details of selected item
  • Details should be displayed outside the listbox and overlaying any controls that happens to be nearby.

The problem about using tooltips is that they disappear after a while. And the problem about using pop-ups is that they do not move, when the window moves (?)

So I'm just looking for some pointers on how to solve this.

alt text

+2  A: 

Use ToolTip object. It has autopositioning and nice graphical style out of the box.

Simply use it like this:

        toolTip.PlacementTarget = yourSelectedItem;
        toolTip.Placement = PlacementMode.Right;
        toolTip.Content = {place whatever you need to display here};

You can control its visibility with the IsOpen property.

CommanderZ
Thanks for pointing that out. I will try both of your suggestions with newly aquired knowledge.
hkon
I think IsOpen is a readonly property. I dont think this will work.
NVM
It isn't. And it works. I'm using it like this in my app. http://msdn.microsoft.com/en-us/library/system.windows.controls.tooltip.isopen.aspx
CommanderZ
You are right!!! And it also has a StaysOpen property. This will indeed work. Is there a way to use it in XAML I couldnt find it. I probably dont know the correct syntax...
NVM
I don't think this can be done purely in XAML, but I might be wrong. Back when I was using this code, I didn't use XAML as all (it was just one WPF control for WinForms app).
CommanderZ
I solved the problem using tooltips as you suggested. I also tried NVM's suggestion using pop-ups, but windows was left all over the place =). I also discovered the ToolTipService and with the following configuration I got the behaviour I wanted; ToolTipService.Placement="Left" ToolTipService.InitialShowDelay="100" ToolTipService.HasDropShadow="True" ToolTipService.ShowDuration="30000"
hkon
+1  A: 

Adorners were built for things like these.

That said, if I were doing this I would set "StaysOpen" on a Popup to false. So when the user clicks somewhere else it will automatically disappear (ie when window is moved). Do you really see your users moving the window so often while looking at the details? Going down the adorners route is not all that easy. It has its own complications.

NVM
Good idea. No they don't generally move their window around. But if they did, it would look very dumb.
hkon
heh, funny if you set the StaysOpen to false. It stays open even if you move the window around. Click on the chrome is not intercepted
hkon
You probably have something else setting it back to IsOpen. I just did a quick check and a click on window chrome most certainly hides it.
NVM
Add some source and I might be able to give you a better answer. I've done something similar on a couple of ocassions previously so I am certain that this approach works.
NVM
Yes it works, but it requires a bit more work to tweak the pop-up behaviour. The tooltip has done this for me. So by using it, I was able to complete the task a bit faster.The pop-up gives superior control and possibilities and I will look into it if I encounter a similar scenario in the future. Thanks a lot.
hkon
No problemo..Of the two upvotes to commanderz answer one is mine! :D
NVM