0
votes

Right now I have a datatemplate that wraps several textblock elements inside of a StackPanel. The textblocks specify information about the bound item, such as the name, description, and a few other properties.

I'm running into the problem where I feel each item in my ListBox (which consumes the datatemplate mentioned above) is displaying too much information. I want to condense it down a little bit and only display extra information if the user clicks on it.

QUESTION: How can I setup my datatemplate to only display the textblock that will display the name of the item, and if the user clicks the name it expands to show the other textblocks? I'm just looking for a painless way to implement this.

Thanks

1
i have a super easy, lazy, sleazy late night suggestion :) put all the detail info in a Tooltip. Add your textblocks to a Stackpanel or smth and put it in the tooltip..Orkun Ozen
Thanks for the suggestions. I've thought about using this approach, but need something a little bit better. Again - something more sophisticated like an expandable textblock.spoof3r

1 Answers

0
votes

I think Zortkun's suggestion of using a tooltip is a good one. A while back I wrote an attached behaviour that automatically moves a TextBlock's text into a tooltip if it is too long:

http://www.scottlogic.co.uk/blog/colin/2011/01/showing-tooltips-on-trimmed-textblock-silverlight/

It is used as follows:

<TextBlock Text="In Hertford, Hereford, and Hampshire, hurricanes hardly ever happen"
            util:TextBlockUtils.AutoTooltip="True"/>