I have an ItemsControl that I want to fit into a small space. Typically it will display less than 3 items, however, I would like the it to indicate when it has more items than it can display and have a popup on the indicator to show all items (which will still be aa small amount).
The current ItemsContainerPanel is a WrapPanel, which I was hoping would provide an Ellipsis type function like TextBlock, but alas it doesn't.开发者_Python百科
I'm having trouble find the "number of elements visible" to display my indicator. Can anybody make a suggestion as to how I might do this?
(The ItemsControl is part of a user control that can be resized, and the ItemsControl will resize as it is in a star sized grid column)
Thanks, Chris
The ToolBar control has that functionality, you can probably replace the ToolBar's ControlTemplate with one that doesn't look like a toolbar.
I think you might have to create a custom panel to do that. You can use this link as a template to get started. In the ArrangeOverride method, you'd want to display only the objects that completely fit in the viewable area and then have some logic to display the ellipsis if that count is less than the total object count.
I like mdm20's solution as it feels like the right way of doing it, but can you get the ItemsControl
's containers (typically a Border control) width, then get the width of the wrap panel and then width of the items template, and the apply some logic around these widths you just got and the width of your border and see if that gives you what your after?
精彩评论