I am using Xamarin.Forms v4.8.0.1534 and I have a list of items being displayed by a CollectionView. I have new items coming in at random intervals and the user may have scrolled the list to look at any historical item. The list needs to operate in two modes:
Monitoring: Where new items need to show immediately when added.
Checking: Where the user will be looking at historical items in the list.
If the list is showing the last item added when a new item is added (Monitoring mode), then the list should scroll to show the new item in full. if the user has scrolled the list to look at historical items then the list should not move when new items are added.
It is an option to add new items to the top of the list or the bottom.
If the option is set to add items to the top of the list and the ItemsUpdatingScrollMode = KeepScrollOffset then everything works as required.
However, there does not seem to be an equivalent setting for adding items at the bottom of the list.
I have tried different settings for ItemsUpdatingScrollMode, but nothing works as required, and I have also looked for ways to check if the last item added is visible in the CollectionView before adding the new one. The idea then would be to use ScrollTo if relevant, but I cannot find any way to check CollectionView item visibility.
I'm not sure If I am missing something obvious but any help would be appreciated especially around ways to check CollectionView item visibility.
I cannot find any way to check CollectionView item visibility.
There is a LastVisibleItemIndex could check whehter item be visible, you could refer to this document:
void OnCollectionViewScrolled(object sender, ItemsViewScrolledEventArgs e)
{
Debug.WriteLine("LastVisibleItemIndex: " + e.LastVisibleItemIndex);
}
The Xaml code:
<CollectionView Scrolled="OnCollectionViewScrolled">
...
</CollectionView>
Related
I have tried the approach described in http://agateau.com/2016/reordering-a-listview-via-dragndrop-3/ to implement drag'n'drop support in a listview.
However, when the amount of items in the list grow there is a problem when scrolling while dragging.
To reproduce the problem, download project from https://github.com/agateau/listviewdragitem/tree/3-placeholders. Triple the amount of items in the list, and try to drag an item (all but first) to the end of the list. The dragged tem will dissapear when the list has scrolled for some time. I have not noticed any signals beeing emitted indicating that the drag has completed.
The first item can be moved correctly for some reason.
Do you have any suggestions what may cause this behavior?
The reason, that the first Item does not disappear is, that it is the currentItem which is protected from deletion.
The reason that the other Items suddenly disappear is, that the ListView instantiates and destroyes the Items as it thinks they are visible. This means: As they would be visible on their original position.
Set the currentIndex to the index of the Item that is being dragged, to prevent it from being destroyed.
Also you could use a DelegateModel and add relevant Items to the persistent group, to prevent destruction.
Is there a way to keep items in the dropdown list in an angular-mutliselect-ui-select control?
I want to click an item, so it is added as selected but keep it in the list (if it is clicked again- nothing should happen).
Straightforward hack is to change $select.removeSelected = true; to false in select.js. A small example is here (see script.js, line: 1244), may be there is a way to do it externally without modifying script.js.
In JavaFX I use a ComboBox containing a New... item that allows to create a new entry. Once it is created and selected, a Delete button allows to remove it.
Adding the item, then scrolling to it in the ComboBox and finally clicking the Delete button shows the following message:
janv. 04, 2016 2:25:01 PM com.sun.javafx.scene.control.skin.VirtualFlow addTrailingCells
INFO: index exceeds maxCellCount. Check size calculations for class com.sun.javafx.scene.control.skin.ComboBoxListViewSkin$2$1
If I do not scroll to the item, it doesn't show this message when it is deleted.
Is there anyway I can avoid this output ? I tried to find a way to scroll back up but failed.
EDIT I currently removed that error using a listener to adapt the visible row count. Although that will probably cause me trouble if the list grows too big:
list = FXCollections.observableArrayList(baseElements());
list.add("New...");
list.addListener((ListChangeListener<String>) change -> combo.setVisibleRowCount(change.getList().size()));
combo.setItems(list);
That removes any scroll as the combo will grow depending on it's contents and thus the error cannot occur anymore. That's not what I expect for a solution though.
Have hou tried reseting the actual item in the combo box before deleting it with something like the code below?
Object value = combo.getValue();
combo.setValue(null);
combo.getItems().remove(value);
I'm going insane over this issue. Basically, I have a TileList with a custom item renderer that has a TextInput in it. Let's say that the list can show 4 items at once, if there are 5 items and I edit the text on the first one, the fifth will be edited also. In general if an item is out of view, it will be change when I edit one that is showing.
Also, I had overriden the TileList class to expose the rendererArray property (so that I could access the texts on each renderer) but it will only return the renderers which are displayed.
Any help is appreciated. I need to know how to override this weird behaviour with itemrenderers that aren't currently displayed. Thanks.
Ok, if anyone runs into a similar issue, here is what you need to do:
First of all, avoid trying to iterate through the itemrenderers like I did. If you need a TextInput or another control on your TileList, make sure that these controls are bound to a property on your data object, otherwise off-screen items will have incorrect values since their itemrenderers will be recycled from the items that left the screen when you scrolled.
If you think it through, any requirement can be solved by iterating through the dataprovider instead of the itemrenderers.
Also, if you try to expose the rendererArray property like I did, notice that you will only be able to iterate through the itemrenderers that are currently displayed, since those that would belong to the items that are off-screen will not be created yet.
I hope this wasn't too confusing..
I would like to add new row on the fly (runtime) to my AdvancedDataGrid.
I can add it to the data model, but couldn’t find a way to make the table render and show the new row.
What i am seeking for is to create an effect of expandable item, where clicking on row will show "additional information" (like a drawer) and clicking on row expand button will reveal it's children.
I saw examples of this for dataGrid (http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_10.html), but not for AdavancedDataGrid.
Only way I found to do this is to add a new child and use openItem, but this cause the other children to be visible as well.
Any help is greatly appreciated
you need to revalidate the whole datagrid after you added a new item, so that all the new elements can become visible.
yourDataGrid.validateNow();
This should help:)