WP7 conditional start page - windows-phone-7

I know I can set up start page in WMAppManifest.xml file.
Is there a way to set start page based on some condition?
I have an application that have 'remember me' funcionality so when app starts I would like it to go directly to some page. If user is not remembered then show log in screen.
Now I show a page and in it's logic I check this and if necessary I navigate to other page.
Is there a better way to do this?
Thanks,
Bartek

From this page, in your App.xaml.cs:
private void Application_Launching(object sender, LaunchingEventArgs e)
{
Uri nUri = new Uri("/Page1.xaml", UriKind.Relative);
((App)Application.Current).RootFrame.Navigate(nUri);
}
Then open your WMAppManifest.xml file and clear the NavigationPage from the DefaultTask line.
<DefaultTask Name ="_default" NavigationPage=""/>

Have you seen this "WP7 - Dynamically change the startup page depending on setting":-
WP7 - Dynamically change the startup page depending on setting

I dont know of any better ways of conditionally redirecting to different pages other than having a loading page which checks and does the redirect for you.

Related

Render personal tabs dynamically in Ms-Teams using custom application

I have created custom application with static tabs defined in manifest file and it is working fine.
Now, our requirement is that we need to render static (personal) tabs dynamically according to provided Site URL by customer.
For ex. When application installed in teams user will get screen where he will asked for Site URL (API) in textbox and submit it. This will internally check data and give response with tab name, tab URLs and other details then I need to render this tabs dynamically in teams.
enter image description here
Please provide solution for this how I can achieve this ?
It is not possible to add static tabs dynamically. Static or personal tabs are always added through the app manifest and are common to all the users using the app. If you want to configure what tabs to show you can try using a channel tab.
As Gousia said, you can't set the contents of the tab dynamically, and you can't add/remove personal tabs programmatically, but what you could try is having your "tab" be just an iframe host, with width/height basically set to 100%, and then dymically loading the content of the iframe

Replace Xamarin forms page without pushasync

I've searched through numerous online posts and can't find a suitable answer for this scenario. It's a pretty common requirement. I have a Xamarin.Forms app with a login page and listing page. When the app is started, the login page is displayed. When they login successfully, I want to display the listing page and prevent them from backing up by clicking on the toolbar back button or the hardware back button.
Change the MainPage
when you start the app you should have
Application.Current.MainPage = new LoginPage();
after login, something like
Application.Current.MainPage = new MyFirstPageAfterLogin();

Absolute URI won't work

Visual Studio 2017, Latest Xamarin.Forms, Latest Prism.
No matter what I try, I can't get my absolute URI to work. I have my app launch from app.xaml to a login page. In the loginpageviewmodel, I do some checks to see if the user is authenticated and if so, then I want to navigate to the mainpage.
I can navigate to the mainpage when not using absolute uri and it works - but the back button goes back to the login page - not wanted.
Code:
if (user.isAuthenticated)
{
navigationService.NavigateAsync("/AppMasterDetailPage/NavigationPage/MainPage"));
}
I've added all the http:// and the myapp.com, etc. ... nothing I try works.
How do I change the uri so absolute will navigate to proper main page and disallow the back button to the login page?
You can check out the following sample project which uses a "Login Screen" and a Hamburger Menu.
I haven't tested an attempted Navigation from OnNavigatingTo, but I wouldn't expect that to work properly as the page hasn't actually been pushed to the stack yet. That said if you did your check to see if the user is authenticated in OnNavigatedTo you could perform the navigation without a problem. If you do not want your user to see the LoginPage then the best I could tell you would be to have a SplashScreen that you first navigate to, and then do your logic from there to decide whether to go to your LoginPage or MasterDetailPage
I have a solution ...
I have app.xaml navigate to the loginpage. In the OnNavigatedTo method, I check for user authentication. If authenticated, then I call
NavigatgeAsync("/masterpage/navpage/mainpage");
and this gets me to the proper mainpage of the app and the back button DOES NOT go back to the login page - it exits app like expected. So the "/masterpage..." is the absolute uri I was looking for.
Next time you should do this instead _navigationService.NavigateAsync( new Uri("http://www.xxxx.com/Index/Navigation/Home", UriKind.Absolute)); this is after you have authenticated and have injected the NavigationService.

Intercepting urls in Windows Phone Browser

In my app I have two pages: Main Page and Display Page. Each page has a browser control.
On Main Page the source of the browser control is set to a website's homepage. If the user touches a thumbnail, I want it to be shown on Display Page.
How do I grab the address of the link that has been clicked/touched and send it to the browser on Display Page?
WebBrowser control has Navigating and Navigated Events.
In the Navigating handler, you can get the clicked link as e.Uri. get that and cancel the Navigation. then send that link to Display page.
void web_Navigating(object sender, NavigatingEventArgs e)
{
e.Cancel = true;
NavigationService.Navigate(new Uri("/DisplayPage.xaml?TargetUri="+e.Uri.ToString(), UriKind.Relative));
}
Note: By the way, sending the e.Uri is not a suggestible way. I would suggest you create a Static propety in the project and use that for sharing the links among pages.

wp7 application bar without navigation

My problem is that the application bar is not displayed on a page if I don't use the navigationservice to navigate to that page. My code is : frame.content = page, but I need an application bar. Any help would be appreciated.
After reading your comments to Derek's answer. can't you have the second page be a static empty XAML file with just some sort of container, a ContentPresenter for instance. Then the user generated content could be placed into that instead of a dynamically generated page.
That way, you can just navigate to the page and populate the content, instead of messing with frame's content property directly.
When your page is loaded, what is the value of the ApplicationBar.IsVisible property?
UPDATE: So, I would imagine that the problem is to do with updating the Content property of the PhoneApplicationFrame, rather than navigating to it using the NavigationService. Presumably, under the hood, it's doing whatever is necessary to show the application bar.

Resources