Class ListView
ListView View renders a scrollable list of data where each item can be activated to perform an action.
public class ListView : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
- Inheritance
-
ListView
- Implements
- Inherited Members
Remarks
The ListView displays lists of data and allows the user to scroll through the data. Items in the can be activated firing an event (with the ENTER key or a mouse double-click). If the AllowsMarking property is true, elements of the list can be marked by the user.
By default ListView uses ToString() to render the items of any IList object (e.g. arrays, List<T>, and other collections). Alternatively, an object that implements IListDataSource can be provided giving full control of what is rendered.
ListView can display any object that implements the IList interface. string values are converted into string values before rendering, and other values are converted into string by calling ToString() and then converting to string .
To change the contents of the ListView, set the Source property (when providing custom rendering via IListDataSource) or call SetSource(IList) an IList is being used.
When AllowsMarking is set to true the rendering will prefix the rendered items with [x] or [ ] and bind the SPACE key to toggle the selection. To implement a different marking style set AllowsMarking to false and implement custom rendering.
Searching the ListView with the keyboard is supported. Users type the first characters of an item, and the first item that starts with what the user types will be selected.
Constructors
- ListView()
Initializes a new instance of ListView. Set the Source property to display something.
Properties
- AllowsMarking
Gets or sets whether this ListView allows items to be marked.
- AllowsMultipleSelection
If set to true more than one item can be selected. If false selecting an item will cause all others to be un-selected. The default is false.
- KeystrokeNavigator
Gets the CollectionNavigator that searches the Source collection as the user types.
- LeftItem
Gets or sets the leftmost column that is currently visible (when scrolling horizontally).
- MaxLength
Gets the widest item in the list.
- SelectedItem
Gets or sets the index of the currently selected item.
- Source
Gets or sets the IListDataSource backing this ListView, enabling custom rendering.
Methods
- AllowsAll()
If AllowsMarking and AllowsMultipleSelection are both true, unmarks all marked items other than the currently selected.
- EnsureSelectedItemVisible()
Ensures the selected item is always visible on the screen.
- MarkUnmarkRow()
Marks the SelectedItem if it is not already marked.
- MoveDown()
Changes the SelectedItem to the next item in the list, scrolling the list if needed.
- MoveEnd()
Changes the SelectedItem to last item in the list, scrolling the list if needed.
- MoveHome()
Changes the SelectedItem to the first item in the list, scrolling the list if needed.
- MovePageDown()
Changes the SelectedItem to the item just below the bottom of the visible list, scrolling if needed.
- MovePageUp()
Changes the SelectedItem to the item at the top of the visible list.
- MoveUp()
Changes the SelectedItem to the previous item in the list, scrolling the list if needed.
- OnDrawContent(Rectangle)
Draws the view's content, including Subviews.
- OnEnter(View)
Called when a view gets focus.
- OnMouseEvent(MouseEvent)
Called when a mouse event occurs within the view's Viewport.
- OnOpenSelectedItem()
Invokes the OpenSelectedItem event if it is defined.
- OnProcessKeyDown(Key)
Low-level API called when the user presses a key, allowing views do things during key down events. This is called from NewKeyDownEvent(Key) after OnInvokingKeyBindings(Key).
- OnRowRender(ListViewRowEventArgs)
Virtual method that will invoke the RowRender.
- OnSelectedChanged()
Invokes the SelectedItemChanged event if it is defined.
- PositionCursor()
Positions the cursor in the right position based on the currently focused view in the chain.
- SetSourceAsync(IList)
Sets the source to an IList value asynchronously.
Events
- OpenSelectedItem
This event is raised when the user Double Clicks on an item or presses ENTER to open the selected item.
- SelectedItemChanged
This event is raised when the selected item in the ListView has changed.