0
votes

I have a MiniToolbar popup that shows up at Mouseover on a ListBoxItem, it needs to show just under the item. (a MouseOver trigger also sets the IsSelected property on the items)

I tried two options :

  1. define the popup on the items DataTemplate
  2. define the popup on the ControlTemplate for the ListBoxItem

Both options work fine, however I was wondering if the popup was recreated each time ?? (please advise)

I think it would be better to define the popup in the ControlTemplate of the containing ListBox rather than the ListBoxItem ? I tried this, but could not find the binding expression for placement property relative to the SelectedItem (it shows up at the bottom of the ListBox, not bottom of ListBoxItem).

Any suggestions ?

thanks in advance. Michael.

1
You're better off leaving the popup in the items DataTemplate. Unless you have thousands of items in your listbox and a very detailed popup, you shouldn't have any performance issues.Stewbob

1 Answers

1
votes

The popup is created one time for each list box item in both cases.

I would not suggest that you use single popup for all items in the CotnrolTemplate for the list box because it significantly complicates things. But if you still want to do so, you can set Placement="Custom" on you popup and specify CustomPopupPlacementCallback. In that callback you can calculate the placement using the position of currently selected item.