1: public class NavigationService : INavigationService
2: {
3: protected Frame RootFrame { get; private set; }
4:
5: public NavigationService()
6: {
7: this.RootFrame = new Frame();
8: }
9:
10: public void Initialize(Window window, bool activate = true)
11: {
12: if (window.Content == null)
13: window.Content = this.RootFrame;
14:
15: if (activate)
16: window.Activate();
17: }
18:
19: public virtual void Navigate(Type destination, object parameter = null)
20: {
21: // avoid navigation if current equals to destination
22:
23: if (this.RootFrame.CurrentSourcePageType != destination)
24: this.RootFrame.Navigate(pageType, parameter);
25: }
26:
27: public virtual void GoBack()
28: {
29: if (this.RootFrame.CanGoBack)
30: this.RootFrame.GoBack();
31: }
32:
33: public virtual void GoForward()
34: {
35: if (this.RootFrame.CanGoForward)
36: this.RootFrame.GoForward();
37: }
38:
39: public virtual bool CanGoBack
40: {
41: get { return this.RootFrame.CanGoBack; }
42: }
43:
44: public virtual bool CanGoForward
45: {
46: get { return this.RootFrame.CanGoForward; }
47: }
48:
49: public virtual void Save()
50: {
51: throw new NotImplementedException();
52: }
53:
54: public virtual void Load()
55: {
56: throw new NotImplementedException();
57: }
58: }