WP7 Get visible items in listbox - xaml

I have a listbox in a WP7 application and I would like to retrieve a list of visible items in the listbox. Actually, I am trying to retrieve the object that is visible so that when my application is tombstoned, I can resume it and write listbox.ScrollIntoView(lastVisibleItem);
If it matters, listbox is bound to a collection of custom objects with a datatemplate for customizing the way it looks.
Thanks in advance.

It's possible to work out how far the list has been scrolled using the technique detailed in this answer.
You could then calculate which item(s) are displayed based on the size of the list and the height of the items displayed.
If different items can be diffferent sizes then this becomes more difficult as you need to consider the height of each individual item.
You also need to remember that only part of an item may be displayed.

Related

What is the best way to create a dynamically growing Stack Item in Fabric React?

I have a use case where I have a sidepanel containing Searchbox, Some MessageBoxes and two lists which get filtered when user searches for something.
The searchbox and messagebox occupies the fixed height but I want both the lists to occupy equal height and grow if the browser resizes.
Also would be nice to shrink the list if there are less items in one of the lists to give more room to the other one.
Here's what the UI looks like...
I'm currently trying to calculate the height and assigning the height to both the lists manually on browser resize event but I was wondering if there's a better way to do that.
Thanks in advance :)
Use a Stack component, specifying the grow attribute on the Stack.Items that wrap your lists.
https://github.com/microsoft/fluentui/blob/master/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Grow.Example.tsx

First element of imagelist selected

I have an issue with an image List which I use for a treeview that I fill with items. By some properties of these, I select an image from the imageList.
My problem is that when I load my list of items in the treeview, the first one gets the first image of the imageList and then it gets the image I set.
By reading the documentation, It seems that there is no way to avoid the first element of the imageList to be selected but there must be some kind of trick I can use.

Scroll to index in GridView

I have a GridView with n number of items. Only 50 are loaded in at a time. Is there a way to jump the GridView control to a specific index without just scrolling through the GridView until that item is available? I dont want to do it that way for obvious visual and memory reasons.
Thanks,
Dom
I'd look into ISupportIncrementalLoading to support data virtualization. That way your ItemsSource might say it has 1000 items, but not load them all and your GridView will be able to skip to say 600-700 range and your ItemsSource will only load the items from that specific range. You can then use the ScrollIntoView() method to do the actual scrolling to the specified item.

Changing the selection of RadioButtons in a GroupBox within a DataRepeater will change the selection of other RadioButtons

I have a DataRepeater in which I have a Label (LabelID) and a GroupBox which contains RadioButtons. I am binding the Labels to a column from a DataTable and what I wish to do is to give the user the chance to select one of the Radio Buttons within each cell of DataRepeater and then upon progress I wish to read the user's selection for each cell. The problem is that when the user starts selecting the radio buttons and scrolls down to select radio buttons for other cells within the DataRepeater, the previous selections change or even the ones that user has not selected yet get selected. I have no idea why this is happening.
Here is the code for what I have done:
LabelID.DataBindings.Clear()
LabelID.DataBindings.Add(New Binding("Text", SomeDataTable, "SomeID"))
myDataRepeater.DataSource = SomeDataTable
I added the GroupBox which contains the RadioButtons in the Visual Studio drag and drop framework.
I tried the following binding as something that I thought might solve the problem, but it did not.
GroupBoxSelection.DataBindings.Clear()
GroupBoxSelection.DataBindings.Add(New Binding("Tag", SomeDataTable, "SomeID"))
I know it has something to do with scrolling the DataRepeater up and down. Because I increased the size of the DataRepeater to get rid of the ScrollBar and this strange behavior won't happen anymore. I cannot keep the DataRepeater that big so I would like to find another solution.
Any help will be appreciated?
I don't know how the DataRepeater works exactly but I wouldn't be surprised if it reused controls to increase performance. If so then your controls may be retaining their values as they are moved. What you might try is creating a user control to contain the RadioButtons and expose a single property that you can then bind. If an instance gets reused then the binding should update correctly as it does for the other controls.

Grouping Controls in Pairs vb.net windows.forms - Dynamic List in grid format

I have pairs of controls: immagebox + textbox = one pair.
I want these to show up in a single column grid/tabular format. Each cell contains one image/text pair.
I want this grid to scroll because the number of pairs is dynamic depending on a user selection.
I suppose I will be adding these controls in code at runtime when the user makes his/her selection.
What is the best way to accomplish that in vb.net? TableLayoutPanel or better way?
One possible approach is the following.
Use a Panel as your container. Inside this Panel you can add a TableLayoutPanel that is defined to be AutoSize=True. Add two columns to your table layout and then add controls in rows as needed. The TableLayoutPanel will then size itself automaticlly depending on the contents.
Now make your Panel be AutoScroll=True and it will automatically add the correct scrollbars so the user can move around and see the contained set of controls.