WP7 pivot headers stop animating when I scoll too fast - windows-phone-7

i have a pivot control with around 20 items that are data binded to an observable collection. One of these items has a long text inside, and I think it delays a bit to data bind. when i scroll too fast and pass this item, the headers start to behave strange, the highlighted header disappears from the screen and i see the other headers. the animation of headers stops.
How can i fix this? any ideas? You can reproduce this problem on a device.
thanx

I would have though that having 20 pivot items was more likely to be the cause of the problem, rather than a long pivot title. However, from a user experience point-of-view I would suggest that 20 pivot items is not going to provide a good user experience especially as all pivot items are loaded on when the pivot is started, so performance is likely to be poor, too.
I would suggest that you consider an alternative approach. Perhaps you could use the Panorama to provide a Hub-like experience with your data grouped into different Panorama items. You could then use a Pivot on secondary pages to show group contents where appropriate.

I can't say that I've experienced this, but then I haven't found a need to use a Pivot with 20 pages.
Could it be that if you're finding the need to flick that quikly through the pages that another UX would be more appropriate?
Perhaps a listbox to present a choice of items allowing ultra smooth and fast scrolling, from which the user can choose to select an item and drill down for details.
The databound project template provides some out of the box handling to demonstrate the concept, but don't be show to roll your own in a vanilla project template.

I've experienced the same issue with a pivot control with only 4 pivot items. The animation gets screwed up when the pivot item containing a long list is selected, so I'm guessing that because pivots don't load their data until the item is selected, that the pivot control is getting screwed up trying to load the long list while animating...so it gives up on the animation.
I haven't really figured out what to do about this yet. One solution is to not bind the data in the pivot item until that item is selected. This isn't really ideal, but it would likely solve the animation issue.

Related

QTableView becomes very slow when multiple rows are selected

I have a model of about 1000 rows, with one of the columns changes every second.
I placed a cusom sort/filter model between the real model and the table view so as for the rows to be filtered immediately after they changed.
Now comes the problem:
If nothing is selected in the table view, everything just works fine; but when I have selected some rows, the table becomes lagging. The more rows selected, the more lagging it is.
Why? hope some one could give me a hint, thanks in advance!
Sorry, but there is a whole lot of potential places where performance can go down in QTableView.
The easiest way to pinpoint the slowdown is to profile the application. If you have the call(s)
that eats the cpu, it's far more simpler to deduce what is the cause and fix it.
Also you don't say much about the design of the custom sort/filter proxy. If you use QSortFilterProxyModel beware it does not scale well.
While painting the (top) header for a table with selection enabled, the function:
bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent) const
is called (twice for each column - but may vary on selection mode).
This function iterates through all selected rows (Line 1333 in "qitemselectionmodel.cpp" Qt 4.8.5).
So if there are many rows selected, the paint for each header column will get really slow.
Same for left header with cols/ rows switched.
The called functions are mostly not virtual - so there seems to be no way to avoid this without completely drawing your own header or hiding the header.
Maybe Qt should optimize this.

when swipe pivot quickly the pivot performance slowly

there
I found that when quickly swiping or flicking the pivot, the pivot will become very obtuse.When the finger off the screen the pivot still traslate between pivotItems a few times.
Is there any way to make the Pivot performance like the Panorama in the situation of quickly swiping or flicking.
I encountered the same problem which was due to using more than 5 tabs each with databinding on them. Each time I swerved to a new page the databinding was triggered thus causing a noticeable delay. (If you keep swirving these requests create a backfill this eventually resulting in multiple background threads for each pivot tab)
I fixed this by collapsing the data on the tabs and only revealing it when the tab was shown for more than 3 seconds. This greatly reduced the databinding and thus data loading. Inmy case though I did have to resort to this because I used the tabs as ways to navigate through dates thus I was facing a potentially limitless collection and had to cycle data across my 5 available tabs. (Microsoft recommends against using more than 5 tabs).
If you have a finite set of less than 6 tabs an easier approach would be to set data binding to ‘one time’ to populate the data. If you have items on the tabs that rely on allowing a control to not just display but also update a value you can always trigger the databinding through that controls events. (be sure to not just use the updated method but also the page.navigateaway event to trigger databinding as navigating away from a page right after updating the value of a control won’t trigger the control.updated event)

pivot with in Panorma ....swipe both together

when i use pivot with in the panorama .pivot are used as a gallery view. i want to move pivot when i swipe it .but the problem is this because of both panorama and pivot are the same gesture event so both are they move .
i want swipe only my pivot view .
I would like some sample code or any other suggestion to do this.
so please give me a solution for doing this and
also give me a link where i easily understand this. Thanx in advance
You shouldn't have a Pivot in a Panorama control. End of discussion.
I believe it is achievable, because I've already solved similar issues with having WebBrowser control inside a custom horizontal-scrollable overview container like Pivot/Panorama, but believe me, it is NOT worth it. I've had to dig very deep into the visualstructure of the controls and attach my own manipulation-handlers to their viscera, manually choose which horiz/verti events to pass and which to cancel, and so on. This is not so easy, takes a lot of time, and doesn't guarantee that on the end you will have something behaving in a way you wanted to achieve in the first place. If you are not bound by some contract to preserve the shape of the UI, please, drop the idea and redesign your UI, just to save on your sanity and nerves.
But, if you are already insane or really want to dig where noone should, start on analysing your UI as a two rectangles: large pano and small pivo, and think which part should behave how on different possible touches/h-v swipes/h-v pans/pinches/so on. Write it down just to for reference, or soon you will probably start making small mistakes that will interfere with your understaning of the flow of the events.
I've checked the version I have, and "my" Panorama uses internally the UIElement.ManipulationXXXX events. In that case:
Display visualtrees of your UI and try attaching manipulation-events to every control. In those events, write/log which control's which handler was invoked. Then make some swipe/scroll on your APP and observe events. Analyze how they were bubbling and try cancelling (e.Handled=true) the manipulation-completed and/or manipulation-delta events somewhere between pivot and panorama. Your goal is to have the panorama see that e.Handled=true, while your pivot must see e.Handled=false. Your Pivot will probably see the event sooner than the Pano, so that point should be relatively easy.
If it fails to work, then you should check your version of the Pano, and check how it detects movements. If, for example, it uses the GestureListener - try the same trick with it. Etc.
And remember, you can always make your own horizontal-overwiew-container that will look like Pano, behave like Pano, and that will work with Pivo better - because it will be your code and you will tell it what and when to move. if you want to go this way, start on google and check all the preliminary Panorama previews that random people have published before that control was published by MS.

Prevent Pivot navigation in Windows Phone

I have an audio recording application for Windows Phone. It consists of a pivot control with two pivot items. One is for recording control, and another one is for reviewing and listening the recorded items.
When the recording is taking place, I need the way to prevent the user from navigating away from the current pivot item, but to retain the feel that an entire pivot item moves, but doesn't flip to the next item, as if there is none.
I know I could use GestureListener from Silverlight Toolkit, but using it I will need to implement a simulation of pivot movement myself.
Is there a build-in way to prevent pivot navigation?
If no, can you point me to an example on how I can animate control movement on gesture flipping?
Is it mandatory that the user has to remain on the one PivotItem?. If not, you could just disable the second PivotItem so that the user knows that it's there, but can't actually interact with it.
secondPivotItem.IsEnabled = false;
Alternatively, you could dynamically insert the second PivotItem when you want it and remove it when you don't. For example, when recording:
mainPivot.Items.Remove(secondPivotItem);
then when you want the second PivotItem to appear:
mainPivot.Items.Add(secondPivotItem);
The only "problem" with this is that when you only have one PivotItem on screen, the user can't scroll. However, this is how a Pivot control is supposed to function.
If you really want the user to scroll back to itself, you could create a blank PivotItem (with no header). Then, handle the Pivot's LoadingPivotItem event. Check if the item that it about to be loaded is the blank one. If so, then use Pivot.SelectedItem = recordingPivotItem to navigate back to the recording PivotItem. You can then use the above method to dynamically add the second PivotItem when the recording is over. This isn't the normal UX for pivots, but should do what you're trying to achieve.
Seems to me that the best solution is making the pivot control invisible to hit test altogether. I simply set PivotMain.IsHitTestVisible = false and set it back to true whenever I am done recording.
There is a good attached property approach on how to make a particular element hit test visible, while casting an entire panorama or pivot item hit test invisible:
Here is the link to a blog post of an author with the source code:
http://blogs.msdn.com/b/luc/archive/2010/11/22/preventing-the-pivot-or-panorama-controls-from-scrolling.aspx
Works for me until the dynamic loading and removing of the pivot items with textblock header will be added to the SDK's pivot control.
The down side of locking a person into a pivotitem or disabling one so that a person cannot navigate is that you are going to frustrate the user. PivotItems are meant to be flicked to and from, and writing an app that has behavior different than this is going to take away from the user experience, because the app is not going to behave the way they expect it to.
Personally, if you are going to lock them into one pivot item, I think you should go ahead and create another page without a Pivot control and navigate to it. Also, whether you choose to do it this way or not, you need to keep in mind that regardless of whether they are locked into a certain pivotitem or they are navigated to another page, the back button must work as expected, or the app won't pass certification.

Sorting/Grouping data in WP7 based on user input using LongListSelector

I’m working on an inventory display app (master/details) for Windows Phone 7 where the user has the ability to change the sorting. The source of the data is XML from the web, and depending on the sort chosen, the results are either a flat list (sorted by name, model number, etc.) or grouped by the selected attributes (color, size, etc.). I'll pre-determine whether the sort returns flat vs. group and it won't be user selectable.
I’m displaying the results in a WP7 pivot control and want/need the different sorts to appear in the same PivotItem (putting the sorts in different PivotItems isn’t really an option). The source for the list is an Observable Collection (actually at this point it’s a CollectionViewSource, but I’m not wedded to either). I’m using the MVVM Light framework.
I’ve played with LongListSelector from the Silverlight Toolkit and it looks like it does what I want. I've read a number of posts (starting with WP7 ListBox Grouping) and actually have it working for the flat list (no sort applied, just default as it is from the source). Now I’m trying to figure out the right way to use it.
My questions:
Is it possible to re-structure the way the data is displayed (flat/sorted vs. grouped) without having to build/maintain multiple observable collections of the same info (one for each sort variant)?
If not, is the best method to save a local copy of the data locally on the phone and work from there? I expect I'd take a hit on complexity but pick up savings on perf/responsiveness.
To display the various results in the same PivotItem, should I create user controls with the appropriate formatting and swap them in to the pivot based on the chosen sort, or can I do it via dynamic ItemSource & ItemTemplate changes?
Is Observable Collection/CollectionViewSource the way to go here?
It’s entirely possible (even likely) the answers are staring me in the face, but I’m new to this stuff and I’ve hit data overload. I could really use some guidance.
Thanks,
Rich
Is it possible to re-structure the way the data is displayed (flat/sorted vs. grouped) without having to build/maintain multiple observable collections of the same info (one for each sort variant)?
I think what you could try is using LINQ to query your given collection, and use that query as the source for your LLS. I'm not sure on how the performance would be, but you can give it a try. Alternatively, IIRC the various *ViewSource collections have ways of changing the view of your data, so you can check those out.

Resources