private void PropagateTemplate()
{
// set the template on all descendants including the legend items
LayerItems.Descendants(item => item.LayerItems).ForEach(item =>
{
item.Template = item.GetTemplate();
item.LegendItems.ForEach(legendItem => legendItem.Template = legendItem.GetTemplate());
});
}