We're using vertical lists for menu selections in our application, with only one item on display. It is working well for user selections using up/down scrolling and SlideTouchHandler. At the end of the interaction, the SlideTouchHander's OnEnd handler obtains the index number of the selected item and stores it in property ItemNum:
var int32 x = VerticalList.Bounds.x1;
var int32 y = VerticalList.Bounds.y1;
var int32 itemNo = VerticalList.GetItemAtPosition(point(x,y));
// If the item is valid ...
if ( itemNo >= 0 ) {
VerticalList.SelectedItem = itemNo; // index is 0 based
ItemNum = itemNo + 1; // display is 1 based
}
var Utility::TouchMenuItem itemView = (Utility::TouchMenuItem)VerticalList.GetViewForItem(ItemNum-1);
The selected ItemNum is then stored in an array of user selections. The problem arises when we need to restore the setting to the menu. So far, I've been unable to figure out how to get the VerticalList to scroll to and display an arbitrary item number. The code in OnSetItemNum is as follows:
pure ItemNum = value;
if (ItemNum > 0) {
var Utility::TouchMenuItem itemView = (Utility::TouchMenuItem)VerticalList.GetViewForItem(ItemNum-1);
if (itemView != null)
itemView.Background.Visible = true;
}
But the call to GetViewForItem(ItemNum-1) always returns null. The documentation for GetViewFor Item() indicates that "the method may return 'null' when asking for the view corresponding to an item lying outside the visible area of the list." So, this is obviously not going to work for items not on display. But, as I said, I've been unable to come up with a workable alternative, and none of the list examples for Vertical/Horizontal lists (they are actually identical except for the list orientation) displays the action that I require.
Any suggestions as to how to select an item not on display are greatly appreciated.