private void InitializeTemplates() { if (!Directory.Exists(ProjectTemplatesPath)) { return; } var templates = new List <TemplateInfo>(); foreach (var path in Directory.GetFiles(ProjectTemplatesPath, "*.xml")) { try { var templateInfo = new TemplateInfo(); templateInfo.Load(path); templates.Add(templateInfo); } catch (Exception ex) { Messenger.Default.Send(new ShowMessageBoxMessage(this, String.Format("Error in Loading {0}", path))); Messenger.Default.Send(new ShowMessageBoxMessage(this, ex.Message)); } } foreach (var template in templates) { var nodes = Root.Children; TreeNodeViewModel <TemplateInfo> lastNode = null; foreach (var split in template.Type.Split('\\')) { var foundNode = nodes.FirstOrDefault(n => n.Text == split); if (foundNode == null) { foundNode = new TreeNodeViewModel <TemplateInfo> { Text = split }; nodes.Add(foundNode); } lastNode = foundNode; nodes = foundNode.Children; } if (lastNode != null) { var node = new TreeNodeViewModel <TemplateInfo> { Text = template.Name, Value = template }; lastNode.Children.Add(node); } } if (Root.Children.Count > 0) { Root.Children[0].IsExpanded = true; Root.Children[0].IsSelected = true; UpdateListView(Root.Children[0]); } }