I have a Universal App solution and on the Windows project I'm using a master-detail view similar to the split-page template. ListView on the left with the items and ListView on the right with the items details.
The binding from the second ListView is done through
ItemsSource="{Binding Path=SelectedItem.Stages, ElementName=itemListView}"
and it works perfectly, when changing selected items (itemListView is the name of the first ListView).
The problem I'm having is with the animation the 2nd ListView does when I select an item with a bigger list of details, let's say from 5 to 8.
When I select the item with the 8 "details", 3 items are added to the end of the ListView on the right and the first 5 swap out (by fading and moving to the right) with the new 5 half a second later. This looks odd and the visual effect is not pleasent.
The same thing happens when changing to a list with fewer items: the last 3 are immediately removed and the remaining 5 fade away to the new ones, but this effect is not that prominent.
Is there anything I can do?
Update
Video
To disable ListViewItems animations all you need to do is clear TransitionCollection
or declare it in xaml as empty:
<ListView>
<ListView.ItemContainerTransitions>
<TransitionCollection />
</ListView.ItemContainerTransitions>
<ListView>
Related
I have a ListView inside of a TornadoFX form builder field that can be added to and removed from by some buttons off to the side. However whenever the contents of the list is modified from the buttons, the list moves vertically downwards. The height of the ListView remains the same, but it's almost as if there is padding being generated along the top whenever the content length is modified. The height change is then reset as soon as there is some change in focus, either by clicking on another component in the view, or by unfocussing and refocussing the window.
I've tried to limit the ability for this to happen by enforcing a max height, both on the form field and on the ListView itself, but neither worked.
Using listeners to print out all the values I could think of that would result in this change, I found that the "bounds in Parent" were changing, adding a value of 17 to both the minY and maxY values. I've not been able to determine where this value of 17 comes from.
The current code for the view is here: https://pastebin.com/6qFVvxvP
I also have some images to help visualize what the problem is:
Before removing content:
After removing content:
I am playing with the <ListView> component. My screen is capable of displaying 9 rows from a data set of 32. However I see in the console that the ListView component triggers the renderRow function 32 times (basically it seems to render in the background all the items of my data set).
I was expecting that the function would be triggered only when a new row appears on screen.
Is this a normal behavior?
Or is there an option that can specify under what conditions the renderRow function should be triggered?
Thanks for your suggestions.
Paul
I figured it out. In fact the rows of the list are build ahead of time so that the scroll of the list remains as smooth as possible.
The default value (in version 0.1.8) is 1000 pixels.
My list items were 20px high. 32 items * 20px = 640px. The first ten were rendered and visible anyway so there were remaining 440px to be rendered.
You can override this default setting by using the scrollRenderAheadDistance attribute of <ListView> in order to optimize your rendering if needed.
https://facebook.github.io/react-native/docs/listview.html#scrollrenderaheaddistance
According to the example on this page, the following code would enable reordering of the items in a ListView. Actually it does, but only using the mouse. If I put the window on my touchscreen and touch the items, it'll show the 'scroll failed' animation (move vertically then pop back) and items won't reorder. Any suggestions?
<ListView CanReorderItems="True" AllowDrop="True">
<ListView.ItemTemplate>
<DataTemplate><TextBlock Text="{Binding}"/></DataTemplate>
</ListView.ItemTemplate>
<x:String>One</x:String>
<x:String>Two</x:String>
<x:String>Three</x:String>
<x:String>Four</x:String>
</ListView>
This is all in an UWP 10.0 project (frameworks: uap10.0), to be specific.
I'd hope this to work without having to write drag and drop code.
Spent an hour on this before moving on, ending up here three hours later trying to solve yet another problem.
Tap & hold, then drag to reorder
Scott uses hamburgers for grips...good choice. The tip is something static has got to be in the list to be reordered, to be able to 'grab' the item or the reordering might not work because gestures are being handled to do something else. My list was short but had checkboxes in it which would get checked/unchecked and you can't reorder after that. In the image, the list is longer than the screen. Once it starts scrolling you can't reorder anymore.
Seems I had been too hasty with my fingers too. I didn't seem to be able to reorder even if no checkboxes changed state or with the exact code from the question, containing only strings.
Quite happy with the amount of code this required ;)
The most landing/hub pages you see are just a GroupedGridView ( for example the actual marketplace app )
But I would like to have a Grouped hub page with different controls.
For example my first control is a ListView that contains some categories.
2nd and 3th control are GridViews with several items in them.
If all 3 controls were GridViews I could easily get this working but it's not.
I can't seem to find a working combination of ScrollViewer with a Grid or Stackpanel to get the actual full Horizontal Scrolling working.
Any idea's or examples on how to create such a landing/hub page with different controls in one horizontal page?
You can use an GridView that is not grouped where each item will be a different control displayed using a different DataTemplate.
Or you can trick the FlipView to behave like a Panorama control for Windows Phone. Details at http://dotnetbyexample.blogspot.cz/2012/08/a-winrt-behavior-to-turn-flipview-into.html
EDIT:
For the first solution you create a base class and create a list with your different objects derived from the base class. Then you use the GridView's ItemTemplaceSelector to select a select an appropriate DataTemplate. See http://coding.kulman.sk/using-different-data-templates-with-gridview-in-windows-8-apps/
I am not experienced in Windows Store (aka Metro) app XAML, so perhaps I am overlooking something simple, but according to books and samples, a vertical scrollbar is a natural part of a ListView control, and unless explicitly disabled will show up when there are invisible items in the ListView.
But on in the case of my app. I have a typical List/Detail page with items in the left pane - they are displayed fine, with scrollbar, and selected item details in the right pane. Selected item contains a collection of subitems, and they are supposed to be displayed with a scrollbar in case there are many of them. I have a simple ListView definition:
<ListView
x:Name="itemCollection"
Grid.ColumnSpan="1"
SelectionChanged="ItemListView_SelectionChanged"
ItemsSource="{Binding Elements}"
ItemTemplate="{StaticResource Custom80ItemTemplate}" />
Strange enough, I never see a scrollbar for this list. Only when I explicitly set its mode to "Visible", I can see a scroll bar, but there is nothing to scroll it with!
Obviously the program believes that the whole list is visible so scroll bar is unnecessary, but what can make it do such judgement?
I've finally fixed the problem. As most of such problems, the error was silly: a Grid control that owns this ListView had an extra (wrong) row definition that had Height property marked with asterisk, i.e. taking all remaining space. But the row that ListView was using had Height marked as "Auto", therefore it expanded to the whole size of its items and never activated its vertical scroll bar.
Try Setting the visibility to auto.