Windows Phone dynamic layout in data template - windows-phone-7

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?

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.

Related

Can NSCollectionViewCompositionalLayout support "growing cells"

I have a collection view showing a simple one-column list with a NSCollectionViewCompositionalLayout. The cells take the full width and have a fixed height.
I would like that, upon an external event, one of the cell grows in height (animated).
That could be for example :
when the cell is selected
when an image shown in the cell is downloaded
I found no way to do this in Apple's doc, when I think this is a fairly common use case. It seems that NSCollectionViewCompositionalLayout is very flexible in positioning cells, but very static. All cell sizes are computed once and for all.
Is there any API for this ? What's the way ?

Qt Quick: Can I use the layout components for item layout, without the overhead of rendering the items to the window?

I want to render a QML subtree manually to a Canvas3D by having all the subtree's items' be-texture-source flag (layer.enabled) enabled, and taking the geometry (x, y, width, height) of each item from the corresponding QML properties of each item (calculated by layouts, anchors, etc), so I know how to position and size each item with OpenGL calls.
I have no problems with implementing this, except for a performance issue: since I'm drawing the items in OpenGL, I don't want Qt to also draw them to the window (this would be doing the same work twice). I could achieve that easily by setting opacity: 0 on the items, but that would probably only fix the visual problem, it wouldn't save performance. I could also set visible: false but then I think the layout components wouldn't be able to do their job correctly.
The reasons I want to implement the described architecture are:
I want to implement custom rendering for some of the items in the subtree, but still use their positions and sizes (calculated by the layout for me) for the custom rendering. This custom rendering is complex enough that it can't be done with QML features alone, and I don't want to use Qt3D.
I could use use another approach: use a separate Canvas3D for every item that I want to render customly. And let Qt Quick render the rest of the items for me normally. That's what I've been doing until now. The problem, however, is that:
The different Canvas3Ds can't share GL resources, so I need to initialize and keep copies of the GL resources in each Canvas3D. This increases load time and memory usage.
The creation time of each Canvas3D (even without my GL init code) is significant, I think
So instead I want to use a single, big Canvas3D.

Famo.us images carousel

How can I create simple image carousel. Let's say I have GridView with two rows and one column. I want to create image carousel in upper row. Can I do that with ScrollView. Any sugestions?
You have the right idea. You can use gridLayout just to keep your sizing in line, and using scrollView is perfectly fine.
I do not know exactly how you imagine such a carousel working, but one option to be aware of in scrollview is the 'paginated' option. This allows you to easily define target positions for scrollview to stop and snap to, similar to a scroll picker on native. Or if you want the sources definition..
* #param {Boolean} [paginated=false] A paginated scrollview will scroll through items discretely
* rather than continously.
The next thing you may want to think about is how a carousel goes round and round and never reaches an end like scrollview would. There is no option for this by default, but I found a way it can easily be done. It may be a bit trickier with smaller images, but here is an example I did for a infinite panorama.
Transforming Panoramas for Virtual Tours with famo.us, has it been done?
The trick was to use a second duplicate image trailing the scrollview and when scrollview was in the right position, we could jump it back to the beginning, with no visual evidence to the user.
Here is the live example..
http://higherorderhuman.com/examples/infinite.html
Hope this helps you get started!

Paging concept using scrollviewer in wp

I am new to wp7. I want to add three images to my page. But not on a single page. It should be on three pages. When i move the image, at that time, the image is changed and i am on the secong page keeping my header and footer fixed.
So how to add three image in one page?
Why do you want to use scroll-viewer?
1) Try using a pivot control without any pivot headers. Add your images to three different pivot items. In pivot the header and footer you specify will remain fixed, only the content will change.
2) Also you can create a single page. Add three images to a list. Bind it to your image control. On flick gesture, change the image URL hence changing the image being displayed but keeping every thing else constant.
I gave you two approaches, try using any one of them which suits you the best. For further information try studying pivots and flick gestures.

What is the "best practice" to fit a slickgrid into tight screen real estate?

We want to use slickgrid to overlay clunky and inflexible tables of data on hundreds of existing web pages built from business forms. Some tables are for display only, others are for user input/update. Thus, the real estate (and column/row counts) is set in concrete. To avoid conflict with the parent page styles, the grid is placed in an iframe. The approach has to take into account a caption bar, optional filter bar on inquiry-only tables, column header bar, and footing pager bar (only if required). Getting the ovarall height correct is the most difficult. It looks like the available tools are:
the geometry of the iframe
the geometry of the grid-container div in the iframe
options.rowHeight
options.headerRowHeight (if inquiry)
line-height css style
Font-size css style.
It seems that there is some mysterious arithmetic going on to calculate the number of rows displayed, the canvas size and the viewport size; and setting some of these items directly with script breaks the grid.
As a simple example, assume the height available is H pixels and must contain R rows of data. Are there any formulas or guidelines that give values to the items listed above? Or must we struggle with trial and error to make a good fit?

Resources