简体   繁体   中英

ItemsControl “Overflow to Popup”

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.

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

ToolBar控件具有该功能,您可以将ToolBar的ControlTemplate替换为看起来不像工具栏的控件。

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.

我喜欢mdm20的解决方案,因为它感觉就像这样做的正确方法,但你可以得到ItemsControl的容器(通常是边框控件)宽度,然后获得包装面板的宽度,然后是项目模板的宽度,以及在你刚刚获得的这些宽度和边框的宽度周围应用一些逻辑,看看是否能给你带来什么?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM