I am making a windowsphone silverlight App for windowsphone OS 8. I am Using windowsphone user controls where I make changes dynamically.
My question is just like the way we create an instance of a phoneApplication Page for Normal .xaml Page using NavigationService.Navigate("Source Uri with unique GUID") . How can I achieve the same effect for a windowsphone User Control Page where I make my dynamic changes to update as there is no Navigation Service.Navigate() method available. ?
Currently I have to Navigate like UserControl-Page-UserControl
When you want to Navigate from a page, you can use NavigationService.Navigate().
When you want to Navigate from a UserControl, You can use the PhoneApplicationFrame to navigate.
Code Sample:
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/MyProjectName;component/MyFolderName/MyPage.xaml", UriKind.Relative));
You need to append a GUID when you want to navigate to a new instance of the same page which you are currently residing.
Related
So i have a splash screen and a LoginScreen, after the user logs in, then he's presented with a MasterDetailPage, and there's a option to logout, what i want to achieve is to clear the masterdetail navigation and go to the login page using Prism.Forms
But when i do "NavigationPage/LoginPage", it still has the MasterDetailPage Navigation active, is there a way to disable this behavior using Prism
MasteDetailNavigation]3]3
Any help would be helpfull
As I can see from your question you want to reset navigation stack and master-detail page and navigate to "clear" page for your login page. If you want to achieve that, you don't want to use NavigationPage/LoginPage you will need to use Absolute navigation, because using Absolute navigation in Prism you will be able to reset the entire navigation stack and it is equivalent to:
Application.Current.MainPage = new SomePage()
You can find more about it here.
But basically what you need to do is to use Prism Absolute navigation like this:
//absolute short-syntax
_navigationService.NavigateAsync("/YourPage"); //notice the prefix /
//absolute URI-syntax
_navigationService.NavigateAsync(new Uri("http://www.brianlagunas.com/YourPage", UriKind.Absolute));
Code example is from Prism Library docs site
Also I recommend you to take a look at my blog post How to make Master-Detail Page Navigation menu in Xamarin.Forms with Prism
Wishing you lots of luck with coding!
I am using Webview to displays an html page that contains 2 inputs of type text and a submit button.I want the app user to be able to fill these fields on the app before launching the webview.Therefore taking the user directly to the result of the search.
Apparently the webview.Document is no longer available.
Any suggestion ?
Once the HTML is loaded into WebView, you can call a method called InvokeScriptAsync through which you can invoke some kind of Javascript.
await myWebView.InvokeScriptAsync("eval", new string[] { "var elem = document.forms[0].submit();"});
This way you can fill the input field, click a button or whatever you need.
I'm trying to migrate my app from WP8 to WP8.1. And I don't get how to navigate to already opened page with another parameters.
For example, I'm showing user info on UserPage giving it user's id as parameter. And when page is already is the content of the Frame I want to open UserPage again but for other user giving it another id.
My problem is that, using NavigationCacheMode set to Required for UserPage means that there will be no navigation with other parameters. But when NavigationCacheMode is set to Disabled navigation with another parameter is success but when I press back button old instance of UserPage is using data from new one.
In WP8 passing new parameters was enough to create new instance of a page with it's own cache. How to do similar in WP8.1 using WRT APIs?
Thanks to Romansz for the tip about using UserControl. Using UserControl binding to a ContentControl and handling BackKeyPress solves my problem with navigation.
In my WP8 app, i have situation where i have to navigate from one page to another and afterwards i need to reload the same page for some reasons.
MainPage.xaml --> Page1.xaml --> Page1.xaml --> Page1.xaml
When user press the backkey should go back to "MainPage.xaml" page.
I tried using the NavigationService.navigate() for navigation, some reason i couldn't able to reload the page. If i pass any unique query strings (eg: Guid) with navigation url, i am able to reload the page. But, when i press back button - it never goes back to Mainpage.xaml page.
Is there any best way to achieve this?
Pass in a query string every time you reload the page (such as your random GUID). On your OnNavigatedTo method check if the GUID query string exists. If it does exist, you know that you don't want this page on the Navigation Stack because it's the reloaded version, so you can remove it by calling NavigationService.RemoveBackEntry.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
string guid = string.Empty;
if (NavigationContext.QueryString.TryGetValue("guid", out guid))
{
//guid exists therefore it's a reload, so delete the last entry
//from the navigation stack
if(NavigationService.CanGoBack)
NavigationService.RemoveBackEntry();
}
}
Use NavigationService.RemoveBackEntry method to remove last navigation stack entry.
You can also remove all elements from navigation history:
while(service.CanGoBack)
service.RemoveBackEntry();
and then add the one you're interested in.
NavigationService.Navigate(new Uri("/MainPage.xaml?" + DateTime.Now.Ticks, UriKind.Relative));
You can use it under a control to navigate to same page
Because I couldn't find any Windows 10 (Universal apps UWP UAP) questions about this, and this one seems to be top result on google search to reload a page, here is a solution:
NavigationService.Refresh();
I'm using Template 10 on my app, so I don't know if it matters here. The lib encapsulates NavigationService on its own INavigationService
I'm creating a web browser. On the "mainpage" it has a button that takes you to the homepage, i'd like to give the user the option of changing the home page on "page1" (settings). on page1 I have "textBox1"(where the user enter desired homepage) and "button1" (set). Could you help me set this up? Is there a way where doing that action can change the source of webBrowser1?
First I would suggest you to download this Programming Windows Phone 7 ebook and explore it to learn Windows phone programming before asking StackOverflow.
Coming to your question,
Create a Settings class in the project and Add a static string property named something like "HomePageUri". Then in your Page1, add the source uri to that "HomePageUri".
Then in your main page, in the OnNavigatedTo event update the WebBrowser's source or you can bind the WebBrowser's source directly to the "HomePageUri" property
Good luck