public void PushPage(PathItem parentPath, string name, Type pageType, object param = null) { PathItem pathItem = CreateOrModify(parentPath, name, pageType, param); if (pathItem != null) { _PathFrame.PushContent(pathItem); } }
public void PushContent(PathItem pathItem) { if (!_PathItemCollection.Contains(pathItem)) { _PathItemCollection.Add(pathItem); ShowLeftContent(); } else { ShowLeftContent(pathItem); } }
private PathItem CreateOrModify(PathItem parentPath, string name, Type pageType, object param) { int nextLevel = 0; if (parentPath != null) nextLevel = parentPath.PathLevel + 1; //去掉更低级的项 foreach (PathChildFrame childFrame in _PathChildren) { if (childFrame.PathItem.PathLevel >= nextLevel) { _PathFrame.RemovePathItem(childFrame.PathItem); } } PathChildFrame pathChild = FindLevel(nextLevel); if (pathChild == null || pathChild.PathItem.PathControl.GetType() != pageType) { object page = Activator.CreateInstance(pageType); UIElement pageUI = page as UIElement; if (pageUI == null) return null; PathChildFrame pageChild = page as PathChildFrame; if (pageChild == null) return null; PathItem pathItem = new PathItem { DisplayName = name, PathControl = pageUI, PathLevel = nextLevel }; pageChild.ParentBaseFrame = this; pageChild.PathItem = pathItem; pathItem.Width = pageChild.GetWidth(); pageChild.ShowContent(param); _PathChildren.Add(pageChild); return pathItem; } else { pathChild.PathItem.DisplayName = name; pathChild.ShowContent(param); return pathChild.PathItem; } }
public void RemovePathItem(PathItem pathItem) { if (_StackRightData == pathItem) { _StackRightData = null; } else { _PathItemCollection.Remove(pathItem); } }
private void ShowLeftContent(PathItem pathItem) { if (_StackLeft != null) { int index = _PathItemCollection.IndexOf(pathItem); _LinkList.SelectedIndex = index; _StackLeft.ChangeContent(pathItem.PathControl, PathContentTranstitionType.LEFT_IN); } }