In your actual implementation you create a new instance of ClassB and call the enableTouch() method on it. Since the method enableTouch() is called in context of the just created new instance, it affects exact this instance only. The other instances existing in the vertical list are not affected by this operation. Every instance is stored and treated individually.
To achive the desired function you would need to call enableTouch() in context of the affected instance existing in the vertical list. You can do following:
1. First obtain the desired ClassB instance existing in the vertical list by using the method GetViewForItem().
2. Once you know the instance, you can invoke the method enableTouch() on it. However, since GetViewForItem() returns the instance interpreted as a generic view, an additional object runtime cast is necessary before you can call enableTouch().
The following source code demonstrates how you call the method for the first item in the vertical list:
// Ask the vertical list for the view corresponding to the first item
var Core::View view = VerticalList.GetViewForItem(0);
// Apply the object runtime cast to ensure that the returned view
// is really the 'ClassB' instance
var YourUnit::ClassB viewClassB = (YourUnit::ClassB)view;
// Successful? Then invoke the method.
if ( viewClassB != null )
viewClassB.enableTouch();
With this approach you access the views individually by specifying the corresponding vertical list item number.
Using this approach you should keep in mind, that the vertical list is optimized to manage the item views very efficiently. This means in practice, the list limits to store the views for the actually visible items only. When you scroll the list, the views are released or reused to display other items.
Thus the above described approach will fail as soon as you scroll the list or you try to access the view for an actually invisible item. This is therefore not the optimal approach unless you know what you do. Anyway, the above description should help you to understand the intern aspects of vertical list, its items and the corresponding views.
From my point of view I would prefer one of the following two aproaches. Which is applicable depends on your aplication case and what you want to achieve:
Approach 1: Do you want the touch handlers to be disabled for ALL items in the vertical list? In this case you don't need to access the items individually and call enableTouch() on them. Instead simply set the property Enabled of the vertical list to the value false. This disables the vertical list from being able to handle and dispatch touch and keyboard events. Accordingly the views embedded in the vertical list are also disabled.
Approach 2: You want the touch handler being disabled individually. Here I would store for every vertical list item its actual enabled state and use it in the OnLoadIItem method to enable/disable the item. As you know, the vertical list itself doesn't store the complete set of all item data. It manages only the few actually visible items. When the user scrolls the list, the list signals the OnLoadItem method asking your implementation for the content of the just exposed item. Thus your implementation of OnLoadItem method has to access some storage where the complete list information is managed. In the simplest case this can be an array. More sophisticated applications use data bases.
The idea of this approach 2 is thus to enhance the information the array/data base store for every item by the additional enabled/disabled state. Then in the OnLoadItem method you accordingly enable or disable the touch handler.
Now in the ClassA you don't access the vertical list items anymore. When you want the enabled state of one of the items being toggled, you toggle ONLY the corresponding state information in the array or data base. Then you Force the list to reload the affected item again. By reloading the item, the OnLoadItem method is called causing the affected list item being updated to its new state you have previously updated in the array or data base.
With this approach you don't need to worry about the items when the user scrolls the list and every item can manage its enabled/disabled state individually.
Hope it helps you further.
Best regards
Paul Banach