In this post i will show you how to remove an specific entry from the OnBackKeyPress while navigationTo you just pass an parameter with the page Uri then with help of that Just place an flag and capture that parameter in " NavigationContext.QueryString "
with this you can easily capture the value lets see the below example:
you page Uri is "/Views/SampleHubPivot.xaml?V={0}";
for above uri you need to send the value for V while NavigateTo.
it acceps string type that page Name that you would like to NavigteTo that will takes you to that specified page while navigating you need to send an flag for value "V" for example if you sent V is "flag".
In the navigated page you need capture that V in an local variable of type string like:
string view = string.Empty;
if (NavigationContext.QueryString.ContainsKey("V"))
{
view = NavigationContext.QueryString["V"];
}
Now if you dont want to Navigate to a specific page you need to pass that V value as you want then with help of this you can stop the OnBackKeyPress like follows:
protected override void OnBackKeyPress(CancelEventArgs e)
{
if (view == "flag")
NavigationService.RemoveBackEntry();
}
then with the above method it allows all BackKeyPress events except for the Value having "V=flag" for this this Navigation entry will removed.
with this you can easily capture the value lets see the below example:
you page Uri is "/Views/SampleHubPivot.xaml?V={0}";
for above uri you need to send the value for V while NavigateTo.
it acceps string type that page Name that you would like to NavigteTo that will takes you to that specified page while navigating you need to send an flag for value "V" for example if you sent V is "flag".
In the navigated page you need capture that V in an local variable of type string like:
string view = string.Empty;
if (NavigationContext.QueryString.ContainsKey("V"))
{
view = NavigationContext.QueryString["V"];
}
Now if you dont want to Navigate to a specific page you need to pass that V value as you want then with help of this you can stop the OnBackKeyPress like follows:
protected override void OnBackKeyPress(CancelEventArgs e)
{
if (view == "flag")
NavigationService.RemoveBackEntry();
}
then with the above method it allows all BackKeyPress events except for the Value having "V=flag" for this this Navigation entry will removed.
No comments:
Post a Comment