Do something after navigate to another page - events

I'm developing a Windows Phone 7 app.
I want to do something after doing this:
NavigationService.Navigate(new Uri(destination, UriKind.Relative));
Is there any event thrown when a page has navigated to another page?

Maybe this helps...
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
http://www.eugenedotnet.com/2011/03/passing-values-to-windows-phone-7-pages-destination-page-instance-within-onnavigatedfrom-method/

Related

Pop a page from stack

I am trying to navigate from Home Page(in shared code) to Detail Page(in the droid,native code). I want to remove the Detail Page and go back to the Home Page when someone press the Accept button. Navigation.PopAsync() does not work for me.
I am trying to navigate from Home Page(in shared code) to Detail Page(in the droid,native code).
As I understand, your Detail Page(in the droid,native code), it's an Activity. You need using DependencyService to open an Activity from Xamarin.Forms.
You could read my answer about Start an Android activity in Xamarin Forms
.
I want to remove the Detail Page and go back to the Home Page when someone press the Accept button.
You just need to close the newly opened Activity, for example :
public class NativeActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.native_layout);
Button native_bt = FindViewById<Button>(Resource.Id.native_bt);
native_bt.Click += (s, e) =>
{
//close the current Activity and go back to the Home Page.
this.Finish();
};
}
}

Windows Universal App Open webbrowser with link

I am making an universal app and when i click a certain button, i need to open the webbrowser with a link. I got the link as a string in a variable but the windows 7 / 8 app ways such as "Proces" and Webbrowser objects give errors.
In windows apps, you can't simply open other apps/programms.
The only posibility is to use the Launcher:
Windows.System.Launcher.LaunchUriAsync(new Uri("http://www.google.de"));
The Launcher looks up the default program/app which is assosiated to the uri-scheme (in this case "http://" for webbrowsers) and forwards this call
others then above you can go Package.app manifest change the start page to the URL that you want or another method by using web control set the source to the URL you needed.
use scope async, it will open link to the mobile,PC default default browser for UWP
private async void Button_Click(object sender, RoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("http://www.fmradiotune.blogspot.com"));
}

Windows phone 8.1 navigation

In my app, I have 3 pages:
MainPage
Page2
Page3
I want to go back from Page 3 to Page2 and to MainPage by Back device button.
So How should I do it?
Help me, please!
Navigation in WP 8.1 is totally different from the WP8, where here you only have to use Frame.Navigate and then give the Uri.
A perfect reference would be this.
Hope it helps!
Create an event for the hardware event like this:
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
And then handle the event accordingly:
void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
Frame.Navigate(typeof(MainPage)); // page you want to navigate to
e.Handled = true;
}
Hope this helps

How can i use NavigationServices in Application_Activated windows phone 7?

im developin an app for wp7 that it holds pictures and notes with password login. But when app running if user press windows button app is running at background and if user press back button it resumes without asking password again.
i tried to Navigate when app activated but i couldnt manage it in Application_Activated method. is there a way to do that? Or could you advice me sth else that solve my problem.
ty.
here is my code im using to navigate,
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
I got around this issue by using UserControls on the MainPage, showing one if the user had not yet logged in and the other if they had, I set these controls up to show/hide based on certains states in the MainPage and then bind that to the MainViewModel:
private void Application_Activated(object sender, ActivatedEventArgs e)
{
// Ensure that application state is restored appropriately
....your code here to load stuff...
App.ViewModel.MainPageState = "ShowThemTheLogin";
}
}

Scrolling WebBrowser control on Windows phone 7

I want to scroll down or up in the webbrowser control on the windows phone 7 using code behind (no javascript). i mean like using some button to scroll down for example. is that possible?
EDIT:
I tried to call a javascript function using InvokeScript, but it keeps giving me an unknown error 80020006. i tried to do this:
public MainPage()
{
InitializeComponent();
webBrowser1.Navigate(new Uri("http://www.msn.com"));
}
private void button1_Click(object sender, RoutedEventArgs e)
{
webBrowser1.InvokeScript("window.scrollBy(100,100);");
}
something wrong in my code?
There is no way to interact with the scrolling of the page inside a WebBrowser control from outside of it.
In terms of doing it with JavaScript look at windows.scrollBy()
update
Try webBrowser1.InvokeScript("eval", "window.scrollBy(100,100);");
But be aware that the page you're viewing may have overridden eval which coudl prevent this from running.
Note that the WebBrowser control was not intended to be used to view websites directly.
Also, have you tried calling scrollBy directly from within your own page?

Resources