A ListBox
is a visual container for ListBoxItem
s. A ListBoxItem
is a control (it inherits directly from System.Windows.ContentControl
and indirectly from System.Windows.Control
. Since every System.Windows.Control
has a Template property of type ControlTemplate, we can control the visual appearance of a ListBoxItem by setting the ControlTemplate in XAML.
The ControlTemplate for a ListBoxItem provides a border around the content of the control – the border is actually a FILLED rectangle and is set to transparent if the item is not selected or does not have the mouse over it. It is set to the default filled colour for selection if it is selected.