A Page without the tab Xamarin.forms - c#

I want a specific page without the tabbed page. I want to remove the tabbed page. However when I use this code it removes the navigation.
NavigationPage.SetHasNavigationBar(this, false);

Based on this link from Xamarin:
It seems you need to create a custom renderer for your page and set ParentViewController.TabBarController.TabBar.Hidden = true in ViewWillAppear()

Related

Xamarin Tabbed Page Content Other than Tab

Quick question,
In Xamarin Forms, when using a Tabbed Page, is there any way for there to be content that remains static between the tabs (other than the tabbar itself)?
For example, if I have a TabbedPage with 3 children (say Page1, Page2 and Page3), can I add other children to TabbedPage that are not a part of the tab itself, but elsewhere, and stay there between tabs?
My use for this is I have 3 tabs in my TabbedPage, which is are at the bottom of the page. I would like a settings button in the top-right of each page, without having to create the same content multiple times in each page that is a child of the TabbedPage.
<TabbedPage xlmns="...>
[Content Here that remains between all tabs, but not a part of the tabbar itself]
<local:Page1>
<local:Page2>
<local:Page3>
</TabbedPage>
Is there some way of doing this easily? Or is there some other method?
Thanks for any help.
You need to check this and create your own control template
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/templates/control-templates/
I would like a settings button in the top-right of each page, without having to create the same content multiple times in each page that is a child of the TabbedPage.
An easy way is using custom control as model. Add the custom control, the button would show in every tabbed pages(page1, page2, page3). If you want to more change on the button, change the custom model, all the changes would show in pages.
Custom Control: ButtonModel
<Button x:Name="btnModel" Text="Button" HorizontalOptions="EndAndExpand" Margin="4,0,8,0"></Button>
Add this in Page1, Page2, Page3
<local:ButtonModel ></local:ButtonModel>
There are a few methods of fixing this. One of these is outlined in another comment very well, however I found that the Xamarin Forms 'Pure' tabs fitted my needs better.
https://www.sharpnado.com/pure-xamarin-forms-tabs/
It was relatively intuitive once I got my head round it and handles integration with mvvm rather well. The tabs need nod span the entire page (other than the tabbar) which is exactly what I wanted.

Open new page outside masterdetailpage

I just new to Xamarin.Form with Prism. I want to load the page in different behavior. The first one I achieve already is in image below.
But I want to do a behavior like below image. Load a new page outside master detail page. How can I do it in prism?
You have figured out how to display the "Hamburger" icon as well as title by doing the following.
NavigationService.NavigateAsync("MasterPage/NavigationPage/DetailsPage")
If a user makes a selection from the actions listed on the master page. For Example, let's say settings.
You have a couple of options here, you can do navigate relatively
NavigationService.NavigateAsync("Settings")
This will navigate to the settings page. This will also display the back button as the second image. Your current page path will be
MasterPage/NavigationPage/DetailsPage/Settings
Now let's say you want the settings page to be the top details page. You have to navigate to it via an absolute path.
MasterPage/NavigationPage/Settings
NavigationService.NavigateAsync("MasterPage/NavigationPage/Settings")
You need to add a new page to the stack, page over existing one. To do that you should do navigation like this:
navigationService.NavigateAsync("Settings")

How to Navigate from Tab Page to Normal WPF Page

I have four tab pages in Tab controller. I wish to navigate from a tab page to Normal WPF page. For that I am using this.NavigationService.Navigate(new Page1()); . I am able to navigate to new page that is Page1 but the tab control is still there. Seems Like only stack panel is getting replaced. Is there any way to do it correctly?
You are calling the Navigate method on the ListBox, so only that control is replaced. By setting the MainWindow's Content, only the new Page will be displayed:
Application.Current.MainWindow.Content = new Page1();

How to store state in Windows 8.1 using Blank Page Template?

I am migrating my Windows Phone 8 App to Windows 8.1 App and I have created a Page with blank page template. In that there are some Items like TextBlock,ComboBox and TextBox. Now, there is an item LocationTextBlock with border around it. When I click on it, it navigates to a new Page LocationPage, where I need to select location and save that object and navigate using Frame.GoBack() method. Now the issue, when I navigate back, I get the object of LocationData but the LocationTextBlock which was created previously is showing null, so I can't populate Location in that TextBlock.
Questions
Is this issue occurring due to Blank Page Template ?
Can it be solved using NavigationHelper Class?
Will using Basic Page Template resolve this issue?
Please suggest with some code or description, whether it can be done using Blank Page template as I have added many lines of code inside it.
It can be done with Blank Page template (although using NavigationHelper would be the prefered way).
What you have to do is set NavigationCacheMode to Enabled in your Page's Constructor:
this.NavigationCacheMode = NavigationCacheMode.Enabled;
This way the Page with all the properties in it is cached. So when you navigate back you get back the state in which the Page was when you navigated from it. However, if you navigate to this page not through backnavigation, you'll still get back the saved state, which you don't want. The solution is to clean up all the resources (initializing the needed variables, setting UI elements to default value etc.) in the OnNavigatedTo(NavigationEventArgs e) method if (e.NavigationMode != NavigationMode.Back). Don't know if it's the best approach, but it'll work.
EDIT:
You could even use a Flyout or a ContentDialog instead of your LocationPage, so you don't need to navigate from the page, thus not needing to cache/save the page.

how to hide the master page content in a web page

I want to open a regular .aspx page in a rad window.But the regular page consists of Site Map.I don't want that sitemap to be displayed when it is opened in rad window.
Please suggest me some solution.
I already tried this:
this.MasterpageFile="..//test.Master";
But in my page it does not work
So you will have ContentPlaceHolders which will automatically inherit from the master page. If you go to the regular .aspx page and head into Design view you will see sections with all the content from the Master Page.
If you click the little right arrow to the right of the area that looks like a Div, you should be able to change the content back to what you have in your regular aspx page.
Make a public property on MasterPage to show hide your site map , on your rad window page access that Property and make it hide.
public bool MyProperty()
{
// get and set your controls visibility
}
Access your property like this.Master.MyProperty = false

Categories

Resources