views:

75

answers:

4

Hi, 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

A: 

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
A: 

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?

Mark
A: 

I'm very interested in the solution, if you developped one. Think about posting it, thanks :-)

Brice
I shall do. I haven't got around to this yet, but I will soon. (And will answer the questions too)
Chris
+1  A: 

The ToolBar control has that functionality, you can probably replace the ToolBar's ControlTemplate with one that doesn't look like a toolbar.

Nir
Yeah, Customizing a toolbar is the best possible option. I dono whether toolbar is available in SL. But, Creating a control for this wouldn't be a good idea. In general, If something isn't available in SL. Then, there should be some possible way of achieving that.
Avatar