Posted 8 years ago by Eric P
Avatar

I love using the HintProperties.Hint for controls like a TextBox and ComboBox but recently I also tried it with a ListBox and it does not seem to work. No suprise but my suggestion would be to add allow the HintProperties.Hint to work for a ListBox. Our use case is our ListBoxes have what we call an "Empty Message" that shows a message (hint) that is center/center on the ListBox to let the user know some extra information when a ListBox is empty. It gives them a "hint" as to how to add items to the list. If this was allowed we would also use the HintTemplate because sometimes we add more than just text, for example a HyperLink or Button.

Comments (6)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Eric,

That's an interesting idea and while we'd like to possibly add it, there are technical limitations in the way.  The only way to know if an ItemsControl has content is to look at its Items collection.  We can attach to an event on that collection to get notified of the collection change, however that event handler doesn't have any reference to the containing ItemsControl.  Since hinting is done as an attached behavior and we don't have an ItemsControl reference, we're unable to tell the ItemsControl whether it now has items or not so that its theme can determine whether to show the hint.


Actipro Software Support

Posted 8 years ago by Eric P
Avatar

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Eric,

Thanks for reporting your findings.  A lot of that is what we've noticed as well.  You might just be best off making some overlay on your own (such as in within a Grid that also contains the ListBox) and binding its Visibility to the ListBox.Items.Count, but with a value converter that converts a number to a Visibility.  You could have a Count = 0 mean Visible and anything else mean Collapsed.


Actipro Software Support

Posted 8 years ago by Eric P
Avatar

Yup that is what we have done in the past. I just wanted to explore the idea of adding a Hint to the ListBox like you guys have done for other controls like the TextBlock because it cuts down on code. I love it. Its frustrating that the ListBox is not directly accessable from somekind of collection changed event. Thanks.

Posted 8 years ago by Markus Springweiler
Avatar

Is there any documentation why (ThemeManager.AreNativeThemesEnabled?) and where (ComboBox, TextBox, ...?) this is working at all? I clicked through all pages of "Actipro Shared Library" but found no mention at all. (Just came across it via Demo "MetroStyleWindow" inside WindowChrome.TitleBarContentTemplate).

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

AreNativeThemesEnabled is described in the "Actipro Themes \ Native Controls" documentation topic.  We have defined themes for all native WPF controls that render consistently with our own controls.  But those are only applied by default on native WPF controls when that property is set to true.  The list of supported controls is in that topic under the style keys portion.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.