XAML Inline Syntax versus Property Element Syntax.

For simple xaml elements “inline” syntax where the property is an XML attribute is preferable:

        <StaticResource ResourceKey="PathVisualTemplate"/>

For more complex elements, “Property Element Syntax” is preferable.

However, Property Element Syntax can also be used in the simple case too:

though this is less pretty than the inline form.

The WPF ListBox: the items it contains.

A ListBox is a visual container for ListBoxItems. 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.