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
Related
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();
};
}
}
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";
}
}
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?
I've developed a WP7 client that uses the Facebook C# SDK, using OAUTH and the web browser control.
Everything works fine except that on the page where the user is requested to accept/reject the access permissions I am asking for, the "Don't Allow" and "Allow" buttons are off the bottom of the browser's screen, and it isn't obvious that the user must scroll down to click on them.
I've tried using all the different display modes (touch, wap, page, popup) and "page" is the only one that shows the buttons on the same page, but then the fonts are tiny. I've also tried different sizes for the browser control.
The example in the SDK has the same behavior.
Has anyone found a work-around for this?
The solution I have found is to use Javascript to change the CSS properties for the element:
private void FacebookLoginBrowser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
// check for when this approve page has been navigated to
if (FacebookLoginBrowser.Source.AbsolutePath == "/connect/uiserver.php")
{
showBrowser();
// do the script injection on the LoadCompleted event - doing it here will appear to work when you have a fast connection, but almost certainly fails over 3G because the elements aren't ready in time to be modified
FacebookLoginBrowser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(FacebookLoginBrowser_LoadCompleted);
}
// etc ...
}
void FacebookLoginBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
FacebookLoginBrowser.LoadCompleted -= FacebookLoginBrowser_LoadCompleted;
// Facebook will likely change this and break our code soon, so make sure you anticipates this
try
{
FacebookLoginBrowser.InvokeScript("eval", "document.getElementById('platform_dialog_bottom_bar').style.position = 'relative';document.getElementById('platform_dialog_bottom_bar').style.top = '-60px';");
}
catch
{
// TODO: display instruction to scroll down if we ever end up here
}
}
I hope that helps. Feel free to contact me if you run into problems
I haven't tried this, but could you use the WebBrowser control's Scale(SizeF) method to change the zoom level of the page?
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/