private List <LegendItemInfo> GetMapLayerLegendItems()
        {
            List <LegendItemInfo> legendItems = new List <LegendItemInfo>();
            TOCWidget             tocWidget   = WidgetManager.FindWidgetByType(typeof(TOCWidget)) as TOCWidget;

            if (tocWidget != null)
            {
                // Map Service Nodes
                foreach (object item in tocWidget.MapContentTree.Items)
                {
                    if (item is TreeViewItem)
                    {
                        TreeViewItem treeNode = item as TreeViewItem;
                        CheckBox     check    = treeNode.Header as CheckBox;
                        if (check.IsChecked.Value)
                        {
                            if (treeNode.ItemsSource != null)
                            {
                                foreach (LegendItemInfo legItem in (IEnumerable <LegendItemInfo>)treeNode.ItemsSource)
                                {
                                    legendItems.Add(legItem);
                                }
                            }
                            else if (treeNode.HasItems)
                            {
                                GetSubLayerLegendiItems(treeNode, legendItems);
                            }
                        }
                    }
                }
            }

            return(legendItems);
        }