Showing a tooltip on a combobox from the itemtemplate (WPF) - wpf

I have a ComboBox with a DataTemplate. The DataTemplate has two controls, each of which has a ToolTip attached to it. The list of items of the ComboBox has the tooltips as expected when you hover over each control. But the selected item area on top of the ComboBox does not display the tooltips, though the controls are rendered as expected. Is there a way to force the tooltips to be displayed?

If you're using Mole or something similar, make sure that your control with the attached ToolTIp has IsHitTestVisible="True". Otherwise, the control is not listening for mouse events and will not recognize that the ToolTip should be shown in the first place.
You may also want to look at binding the ToolTip of the selected item to the ContentPresenter in the ComboBox since, after selection, your SelectedItem becomes the content of the ComboBox. You may need to override the ComboBox template and make sure the ContentPresenter can accept mouse input in order to force your ToolTip's visibility.

Related

WPF TabControl - In need of a default message before tabs load

I have a WPF TabControl who's TabItems are MEF'd in at run time. However, they are MEF'd in only when a certain item in a left-hand treeview is selected. What I'd like to do is display a centered message inside the TabControl indicating "No Active Scenario Selected". I tried adding a TextBlock inside the TabControl but what I got was a TabItem instead. Any ideas?
One way to do this is simply by putting a TextBlock on top of the TabControl and show it when the TabControl doesn't have any Tabs added.
You can bind the Visibility of the TextBlock to the HasItems property of the TabControl and use a value converter (BooleanToVisibilityConverter or your own implementation) to show and hide the TextBlock.

In the ListBoxItem template, how do I change the visual state of the item based upon IsSelected?

I'm wanting to increase the size of a selected item in a ListBox and show extra controls. I'm not sure how the ListBoxItem template knows whether the item is selected or not. In the past I would wrap all of my items in radio buttons but it is very clunky and didn't utilize the ListBox selection at all. I would really like to have a better way. Ideally, I would like the change to be in a visual state so I can animate the transition.
Thanks.
ListBoxItem already defines the visual states Selected and Unselected. See ListBox Styles and Templates for how the ControlTemplate in ListBoxItem's default style handles these states.

WPF popup on ListBoxItem

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 :
define the popup on the items DataTemplate
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.
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.

Silverlight ListBox OnMouseOver event

I have a ListBox that is being bound to data from a WCF service. When the user hovers over one of the ListBoxItems, I want to display related text in a separate region. Each of the items in the data collection to which the list is being bound has a Description property.
How can I wire up to the mouseover event for a particular ListBoxItem?
Have a look at this thread, I think you might find your answer:
WPF Listbox Show Button in ItemTemplate on MouseOver

WPF Datagrid, Setting the background of combox popup

I would like to change the color of the popup background when using a DatagridComboboxColumn in the WPF Toolkit datagrid. I've edited the Template for a normal Combobox and it works great for selected item and other properties but the background stays white. I've used Snoop to do some research into the template and it claims that the DropdownBorder's background is set by the parent template but I can't figure out which template that is.
Any ideas?
You have to change ItemContainerStyle, that contains style and template to control background/selected color etc. Because ItemContainerStyle of ListBox and ComboBox has IsSelected property that can be used for setting trigger for changing background color.

Resources