navigationservice

How to clear whole navigation history hosted by the WPF Frame control

梦想与她 提交于 2021-02-07 06:49:38
问题 In a WPF application the Frame control is used to host/navigate pages. I'd like to clear the navigation history. There is NavigationService.RemoveBackEntry() method which can be used to clear the backward portion of the history. But what about the forward navigation history? How to clear this part? What is the best practice? Thank you in advance. 回答1: Here's the code I used to clear a Frame's navigation history: public void ClearHistory() { if (!this.Frame.CanGoBack && !this.Frame

NullreferenceException when using NavigationService

这一生的挚爱 提交于 2020-01-06 08:12:12
问题 I'm encountering a problem with my WP7 app: I'm trying to make a login page prompt only when the app can't detect any stored username or password values; however, I keep running into a NullReferenceException when I try to navigate to my login page. My code looks like this, and it's in the contructor: if (!checkLogin()) { NavigationService.Navigate(new Uri("/LoginPage.xaml", UriKind.Relative)); } And checkLogin is just a function that returns either true or false depending or not the isolated

MVVM Light Navigation Service - Change MainWindow Title and Size

℡╲_俬逩灬. 提交于 2019-12-25 09:17:58
问题 I'm creating a new WPF application with (my first WPF app): .Net 4.0 MVVM Light C# MahApps Metro I've already implemented navigation using the Navigation Service in MVVM Light. I'm using a MainWindow and Pages in order to accomplish the same. In my MainWindow.xaml I have a MainFrame that is changing my current View: <Controls:MetroWindow x:Class="App.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns

windows phone navigation immediately after loading page

狂风中的少年 提交于 2019-12-19 12:04:33
问题 I have 2 pages.(MainPage.xaml,second.xaml) MainPage.xaml is the Login page. In this page I send login and password, and receive result. I save them(result) in Isolate Storage and navigate to the second.xaml page; When i start this application in the next time, i extract data from Isolate Storage and I want to navigate the second.xaml immidiately, but i don't know how I try write public MainPage() { InitializeComponent(); //function for Isolate storage InitializeSettings(); NavigationService

Clearing backstack in NavigationService

跟風遠走 提交于 2019-12-18 05:54:22
问题 I am navigating through different pages within my application. After I login, I come to home page from where the navigation starts. During navigation, when I come to homepage, I want to go to the login page by pressing BackKey but I can only navigate to previously navigated page. I could have overriden the BackKeyPress event to navigate to the Login Page but in LoginPage I should again override the Backkeypress otherwise there appears to be cycle between loginpage and homepage on backkey

What determines whether NavigationCommands.BrowseBack calls the page constructor?

痞子三分冷 提交于 2019-12-14 03:51:18
问题 I have two pages with similar logic in them. Load the page, click some buttons that will show/hide other buttons, continue to next page. When I hit the next page, if I click the back button I am returned to the previous page. The difference is that one page (FirstPage) will have the constructor called when I click the back button, which has a call to reset the defaults. The other page (SecondPage) doesn't get the constructor called and I'm not sure why. public FirstPage() {

How to navigate to a xaml page from class

十年热恋 提交于 2019-12-13 04:03:30
问题 In my application, I have a class Chronometer which use a dispatcherTimer and Tick method. Each second, a variable decrease. I would like that when the value of the variable is 0, a new xaml page is load. I try to use NavigationService but this method work only in a xaml.cs file. My xaml page which is visible when the variable decrease is : WordPage.xaml The xaml page that i want to display is : FinalPage.xaml Can you realize what I want? Please help me EDIT : My constructor of my class is :

WPF Navigate Pages from outside frame

对着背影说爱祢 提交于 2019-12-11 16:46:20
问题 I have to create wpf browser application.It have 2 frames: <DockPanel> <Frame Name ="MenuFrame" Source="Menu1.xaml" Height="Auto" Width="150" NavigationUIVisibility="Hidden" BorderBrush="#35000000" BorderThickness="1"> </Frame> <ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> <Frame Name ="ContentFrame" Source="Content.xaml" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" NavigationUIVisibility="Hidden" BorderBrush="

Navigation Service in WPF

喜夏-厌秋 提交于 2019-12-08 14:46:47
问题 I created a simple application in WPF and added one page. I also added one button to the main window, and when I click on it, it brings the page added. But now, I want to go back from the page to the main windows by using another button. I tried to use: MainMenu n = new MainMenu(); this.NavigationService.Navigate(n); but I got this error: Object reference not set to an instance of an object. Any help? 回答1: I believe you are looking for: void backButton_Click(object sender, RoutedEventArgs e)

Is there any way to get previous page url in silverlight navigation application

淺唱寂寞╮ 提交于 2019-12-02 07:27:02
问题 Is there any way to get previous page url in silverlight navigation application. I am using navigation Service. 回答1: There is no way to get the navigation history, you can store it by yourself by listening the navigation service event NavigationService.Navigated (or Frame.Navigated for frame navigation). private List<Uri> _navigationHistory = new List<Uri>(); void onNavigated(object sender, NavigationEventArgs e) { _navigationHistory.Add(e.Uri); } private Uri getBackUri() { return