public void InitControl(NavMenuItem item) { if (item == null) return; if (Segments.Any()) { Segments.Clear(); stkRoot.Children.Clear(); } var control = new NavigationControlSegment() { CurrentLevel = 0 }; control.NavMenuClickEvent += OnNavMenuClick; var items = new ObservableCollection<NavMenuItem>(); var menuItem = new NavMenuItem() { Title = "Вся компания", Id = item.Id }; menuItem.Items.AddRange(item.Items); items.Add(menuItem); control.NavItems = items; control.Status = NavSegmentStatus.Current; stkRoot.Children.Add(control); if (!Segments.ContainsKey(control.CurrentLevel)) { Segments.Add(control.CurrentLevel, control); } else { // // if (control.NavItems.Any ()) { // foreach (var segment in Segments) { // if (segment.Key < control.CurrentLevel) { // segment.Value.Status = NavSegmentStatus.Previous; // } // } // } Segments[control.CurrentLevel] = control; } control.SelectFirstItem(); }
static NavMenuItem GetNavMenuTree(TreeMapPrItem rootItem) { NavMenuItem result = null; if (rootItem != null) { result = new NavMenuItem () { Id = rootItem.PrId, Title = rootItem.PrName }; if (rootItem.Items.Any ()) { result.Items.AddRange (GetChildrenNavMenu (rootItem)); } } return result; }