private void RebuildTemplate(FeatureLayer flayer) { var templates = new List<TemplateItem>(); FeatureServiceLayerInfo serviceInfo = null; var gdbFeatureTable = flayer.FeatureTable as ArcGISFeatureTable; if (gdbFeatureTable != null && !gdbFeatureTable.IsReadOnly && flayer.Status == LayerStatus.Initialized) { try { serviceInfo = gdbFeatureTable.ServiceInfo; } catch{} } if (serviceInfo != null) { var cmd = new InvokeCommand(OnItemClicked); var renderer = flayer.Renderer ?? (serviceInfo.DrawingInfo == null ? null : serviceInfo.DrawingInfo.Renderer); if (serviceInfo.Templates != null) { foreach (var template in serviceInfo.Templates) { var item = new TemplateItem { Layer = flayer, FeatureTemplate = template, Command = cmd, }; templates.Add(item); if (renderer != null) { var g = new Graphic(template.Prototype.Attributes ?? Enumerable.Empty<System.Collections.Generic.KeyValuePair<string, object>>()); // Need to disambiguate from winstore toolkit KeyValuePair item.SetSymbol(renderer.GetSymbol(g)); } } } if (serviceInfo.Types != null) { foreach (var type in serviceInfo.Types) { foreach (var template in type.Templates) { var item = new TemplateItem { Layer = flayer, FeatureType = type, FeatureTemplate = template, Command = cmd, }; templates.Add(item); if (renderer != null) { var g = new Graphic(template.Prototype.Attributes ?? Enumerable.Empty<System.Collections.Generic.KeyValuePair<string, object>>()); item.SetSymbol(renderer.GetSymbol(g)); } } } } } _templatesByLayer[flayer] = templates; }