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.
Related
I am using the MahApps Panorama Control in my project by linking the Mahapps.Metro.dll so I can't change the XAML-Code of the Panorama Control directly.
I thought it would be possible to override values in my MainWindow.xaml but when I do so nothing changes or maybe I change the wrong property.
The problem with the Panorama Control is that the selected item has a white border and I can't find a way to remove this selection style. I tried several solutions like changing the style or changing the control template (How to disable highlighting on listbox but keep selection?) but my changes have no influence of the Panorama Control.
There you can see the Panorama Control XAML.
This is an issue with the way that the Styles are inherited, and it's tricky to see how the ListViewItems and ListBoxItems work together. I fixed this by inserting the following in the code behind. It does, however, lose your selected item:
var listbox = MyPanorama.FindChildByType<ListBox>();
if (listbox != null)
{
listbox.SelectedIndex = -1;
}
FindChildByType is a simple search to return the first ListBox that is found under the Panorama. If you have a search by name the x:Name of the template listbox is "items".
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.
I have a WPF ListBox control which displays items of an RSS feed. I occasionally check the source of the RSS feed for new items. Once I detect a new item I add it to the observable collection which immediately adds the new item to the ListBox display.
Is there a way to 'slide in' the new item from the top, pushing down the existing items? How would I achieve such an effect? Can it be done with a ListBox, or do I need to resort to my own container, such as a StackPanel and animate for example the Height of newly added controls programmatically?
I just posted an answer to this question which is very similar to yours.
WPF how to animate a list of components
It can be done with a ListBox. Use the ItemContainerStyle to style the ListBoxItems that the binding creates for you: this style can include animations, e.g. by adding an EventTrigger for the Loaded event to the Style.Triggers, and transforms. For example, in your trigger action you could animate the Height so the item expands into place, or if the height is unknown you could have your style set a ScaleTransform and in your trigger action animate the ScaleY of that transform from 0 to 1.
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.
I have 7 tabitems in my tabcontrol and the width of the tabcontrol is only 500. Therefore the tabitems are displayed in 3 rows. I want it to be shown in a dropdown at the end of the tabcontrol just like an overflow tabcontrol. How can I create it?
take a look here on CodeProject. I am thinking this will do what you want. Basically all you have to do is make a control template for your tab control.