Ejemplo n.º 1
0
        public static void NavigateTo <Owner, T>(string frameName) where T : Page, new() where Owner : DependencyObject
        {
            List <Frame> frames = ComponentNavigator.GetComponent <Owner, Frame>();

            if (frames == null || frames.Count == 0)
            {
                return;
            }

            Frame frame = frames.Where(x => x.Name == frameName).FirstOrDefault();

            if (frame == null)
            {
                return;
            }

            Page page = GetPage <T>();

            while (_history.Count >= _maxHistoryPath)
            {
                _history.RemoveAt(0);
            }

            _history.Add(page);

            frame.Content = page;
        }
Ejemplo n.º 2
0
        public static void GoBack <Owner>(string frameName) where Owner : DependencyObject
        {
            if (_history.Count <= 1)
            {
                return;
            }

            List <Frame> frames = ComponentNavigator.GetComponent <Owner, Frame>();

            if (frames == null || frames.Count == 0)
            {
                return;
            }

            Frame frame = frames.Where(x => x.Name == frameName).FirstOrDefault();

            if (frame == null)
            {
                return;
            }

            Page page = _history[_history.Count - 2];

            _history.RemoveAt(_history.Count - 1);

            frame.Content = page;
        }