private void Tile_Click(object sender, RoutedEventArgs e) { Tile tile = (Tile)sender; WorkItem item = (WorkItem)tile.Tag; if (WindowList.ContainsKey(item)) { WindowList[item].Close += frame_Close; ContentControl.Content = WindowList[item]; return; } WorkFrame frame = new WorkFrame(); frame.MainTitle = item.Name; WorkPage content = item.GetWorkPage(); WindowList.Add(item, frame); MenuItem menu = new MenuItem(); menu.Tag = frame; menu.Click += Menu_Click; menu.SetBinding(MenuItem.HeaderProperty, new Binding { Source = frame, Mode = BindingMode.OneWay, Path = new PropertyPath("Content.Title") }); WindowMenu.Items.Add(menu); frame.Close += frame_Close; frame.Close += (s, ee) => { WindowList.Remove(item); WindowMenu.Items.Remove(menu); ContentControl.Content = StartMenu; }; ContentControl.Content = frame; frame.NavigationService.NavigateTo(content); }
protected virtual void OnNavigatedFrom(WorkPage page) { if (NavigatedFrom != null) { NavigatedFrom(this, page); } }
protected virtual void OnNavigatedTo(WorkPage page) { if (NavigatedTo != null) { NavigatedTo(page, this); } }
public void NavigateTo(WorkPage page) { WorkPage old = Frame.Content; Frame.Content = page; if (old != null) { History.Push(old); old.BaseNavigateFrom(page); } if (page != null) page.BaseNavigateTo(old); if (Navigated != null) Navigated(old, page); }
internal void BaseNavigateFrom(WorkPage page) { OnNavigatedFrom(page); }
internal void BaseNavigateTo(WorkPage page) { OnNavigatedTo(page); }
protected virtual void OnNavigatedFrom(WorkPage page) { if (NavigatedFrom != null) NavigatedFrom(this, page); }
protected virtual void OnNavigatedTo(WorkPage page) { if (NavigatedTo != null) NavigatedTo(page, this); }