开发者

How to show an image in group template in a LongListSelector

Let's go with the toolkit example of LongListSelector, but say I'd like to display a f开发者_Python百科lag of its country with the city name, in the GroupHeader. Is this even possible?

If yes, how and what kind of a strategy do you propose? Remember the cities are grouped by name, and the Flag Image path is not part of the key. The Country name and FlagImage could be in a master table or List for lookup.


It appears to that the simplest solution is to add an image (which uses a converter) to the GroupItemTemplate and the GroupHeaderTemplate and have a lookup up in the converter which determines which path to use for the image based on the key. (Option 1)

Alternatively you could use a compound key (of the group name and image path) for the List being displayed but this might require changes to the toolkit code and so is, potentially, more complicated. (Option 2)

I'd be more drawn to the second option as it feels cleaner to me. The first option feels like a bit of a hack, and I only like to use converters when I have to.

The second option requires you to be happy with the potential long term consequences of adding your own customizations to an open source project which could change in the future in ways which could break your changes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜