0
votes

I need to have a dynamic layout inside List box item.

Example of such layout would be the news feed on Facebook. To simplify, let's narrow it down to one news item type: Somebody added N photos. I already have an algorithm which takes image sizes and produces optimal layout.

  • I don't want to have 20 images with bound Width, Height, Margin, Visibility.

  • I do have to have virtualization enabled.

How can this be done on Windows phone platform?

1

1 Answers

0
votes

Easiest method:

Place ItemsControl inside list box item. Set ItemsControl's width and height as your layout algorithm tells you to. Set ItemsPanel to be a grid. In the data template, place an Image, set margins as your layout algorithm tells you to.

Images wont be virtualized, listbox items (containing the whole ItemsControl with images) will.

Most correct method (only required if you have many images and/or large images so that single item exceeds 2048px):

Inherit from e.g. VirtualizingStackPanel, override MeasureOverride and ArrangeOverride to implement your custom layout, then spend ~2-10 days fixing virtualization-related issues in your code. This way virtualizes everything, however the time is estimate (i never did it myself), and I can't guarantee you'll eventually succeed.

Intermediate method: redesign your layout algorithm so it layout images in the rows. Use single virtualizing listbox or ItemsControl, split your item into smaller rows, each row containing single row of images.