Multiple Content Pages inside one Tabbed Page - xaml

I am doing my app from scratch without using TabbedPage template and I really don't know how to put my multiple Content pages inside one TabbedPage. Right now my Tabbed Navigation XAML looks like this:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:parkingapp="clr-namespace:ParkingApp.Views"
x:Class="ParkingApp.Tabbed"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
android:TabbedPage.ToolbarPlacement="Bottom">
<parkingapp:Profile Title="Profile"></parkingapp:Profile>
<parkingapp:MainPage Title="Parking" ></parkingapp:MainPage>
This works fine, I can navigate to Profile and Parking, but inside Parking I have button to navigate to another Content page and once I'm inside that another Content page my Tabbed Navigation bar is not showing and I want it to be shown in all of my Content pages.

if you want to navigate within a tab, place the contents of that tab inside of a NavigationPage.
<NavigationPage>
<x:Arguments>
<parkingapp:Profile Title="Profile" />
</x:Arguments>
<NavigationPage>
Example

Related

Xamarin multiple flyouts in one page

I've been looking at Xamarin.Forms Shell. The flyout available in Shell by default allows a slide from the left side of the screen or a tap on the toolbar menu button to have the flyout appears on the left side of the screen.
I've also seen a variation of this, where the toolbar and flyout are flipped, so the toolbar button and flyout are on the right side of the screen.
My question is - I want to have multiple flyouts available on the screen. Shell works, but it APPEARS that I can only have one flyout if I use Shell (either the left or the right, but not both). Is there a way to use multiple flyouts with Shell?
Or, is there a better solution using something else?
You can use SideMenuViewPage from Xamarin.CommunityToolkit package, it is already available but not documented yet.
You may find the full sample of the code below in SideMenuViewPage.xaml
Sample
<xct:SideMenuView x:Name="SideMenuView">
<!-- MainView -->
<StackLayout BackgroundColor="Gold">
<Label Text="This is the Main view" VerticalOptions="Center" HorizontalOptions="Center"/>
</StackLayout>
<!-- LeftMenu -->
<StackLayout
xct:SideMenuView.Position="LeftMenu"
xct:SideMenuView.MenuWidthPercentage=".5"
xct:SideMenuView.MainViewScaleFactor=".95"
BackgroundColor="Orange">
<Label Text="This is the left menu view"/>
</StackLayout>
<!-- RightMenu -->
<StackLayout
xct:SideMenuView.Position="RightMenu"
xct:SideMenuView.MenuWidthPercentage=".3"
xct:SideMenuView.MenuGestureEnabled="False"
BackgroundColor="LightGreen">
<Label Text="This is the Right menu view"/>
</StackLayout>
</xct:SideMenuView>
Available properties
Property
Description
MenuWidthPercentage
Set the width percentage of your menu relative to it parent.
MainViewScaleFactor
Set the scale percentage which MainView will be scaled to when a side menu (left or right) is opened.
Position
Specifies position whether it is right or left or main, if not specified it will be considered as the MainView.
MenuGestureEnabled
Enable/Disable side swipe gesture option to open/close menu/view.
Open/close side menu views (flyout)
From code
Left and right menus/views are opened either by swiping gesture or by setting the property State of the SideMenuView that you defined in your xaml:
SideMenuView.State = SideMenuState.MainViewShown; //show main view and close both left and right menu view
SideMenuView.State = SideMenuState.RightMenuShown; //Open right menu view
SideMenuView.State = SideMenuState.LeftMenuShown; //Open left menu view
From xaml
By default left and right menus are closed (default value of State property is MainViewShown), if you want initially to have a menu opened, change it value in your xaml:
<xct:SideMenuView x:Name="SideMenuView" State="LeftMenuShown">
A mixed approach would be to bind State to a property and change it in your code according to your logic.
Note
For now it is supported for iOS and Android only (not supported for uwp).

XamarinForms Pagetypes

I am starting with XamarinForms. I would like to create application which look line Facebook Messanger. The points is I am looking for tip how to achive bottom bar with buttons to navigate throught views.
I was trying to do it with CarouselPage but I dont see option to make static bottom bar. As I see CarouselPage can only contain collection of ContentPages
<CarouselPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:xxx"
x:Name="ThisPage"
x:Class="xxx">
<ContentPage>
<ContentPage.Content>
<Grid>
</Grid>
</ContentPage.Content>
</ContentPage>
<ContentPage>
<ContentPage.Content>
<Grid>
<Label Text="Page1"></Label>
</Grid>
</ContentPage.Content>
</ContentPage>
<ContentPage>
<ContentPage.Content>
<Grid>
<Label Text="Page2"></Label>
</Grid>
</ContentPage.Content>
</ContentPage>
</CarouselPage>
I did also try to make it as it was possible in XAML - create stacklayout at the bottom with navigation buttons and create content presenter to the rest page and dymanically change his content but it did not work as expected.
Can someone give me any tip ?:)
I think you have many ways to do it. I don't use Fb Messenger (sorry) but I have an idea of what you need.
First I will remind you that a "TabbedPage" will give give you this bottom bar on iOS but will be on the top for Android...
Next, you can use a third party component. I've already seen several in the past I think (If you 'DuckDuckGo' 'xamarin forms bottom bar' for instance you should find good things. You can try this one for example that renders the bottom bar on Android pretty well (and the native bar for iOS): Github BottomNavigationBarXF.
Finally, has you mentionned it, you can try to make your own navigation bar. It should not be difficult if you have some design skills. Make your bottom bar control that accepts "navigation buttons", then change the 'ContentPresenter.Content' property (in the page that owns your bottom bar) in response of the button clicks...
Exemple of the Github project (BottomBarNavigationXF):
(Android) (iOS)
Tell me if it's what you was looking for, or mark as answered if it's ok for you !

CommandBar hides page content

I am using Page.BottomAppBar to place a CommandBar at bottom of the page.
It hides the bottom content of the main view. How can the app bar "push" the content to show it all? The content is a ScrollViewer.
UPDATE:
The Commandbar code is:
<Page.BottomAppBar>
<CommandBar>
....
</CommandBar>
</Page.BottomAppBar>
Then I have a grid, and the ScrollViewer is in one row of the grid. If I remove the app bar, everything works fine. The cursor is always visible, but when the app bar is visible, it overlays the content, like the images show.
The problem is that CommandBar overlays the page content. So, when InputPane appears, Windows ensures that the input pane doesn't cover the focused element, but Windows puts the CommandBar over the content, hiding the focused control. I know that CommandBar overlays the page content by design, but there is a way to avoid it?

Universal Windows App layout page

I'm starting a new universal windows app project. Normally I do web developer but have been asked to do a Universal Windows Application.
I'm starting to get somewhere now and have been using MVVM Light and have a couple of views set up.
Anyway here is my question, is there a way for me to have a "Layout" page, similar to what I would have it ASP.NET MVC?
For example, I have the main xaml page in my app, and the root control in that page is a SplitView. I have it so that when I click a button in the split view pane it takes me to the correct xaml view for that button. The thing is this page doesn't have the split view so I no longer have any navigation.
Surely I don't need to duplicate my menu across every view? I assume I'm missing something blindingly obvious.
Thanks,
The Splitview works this way that the page containing the split view will always be active (I normally call this page shell.xaml)
In here you can place your hamburger menu and add other things that should be visible all the time. Then you create a frame inside the splitview where your child pages live. handling navigation should only navigate using this frame and not the main page.
Here is a working sample that might explain this better:
https://code.msdn.microsoft.com/Sample-splitview-with-edcc2ca9
I think you need something like this.
You have to navigate your pages just to frame in SplitView content, not to default application's frame.
<SplitView>
<SplitView.Pane>
Your menu
</SplitView.Pane>
<SplitView.Content>
<Frame Name="ContentFrame" />
</SplitView.Content>
</SplitView>
And than in code-behind set the page you want like default
public MainPage()
{
this.InitializeComponent();
ContentFrame.Navigate(typeof(Homepage));
}

How to make a LoginPage with a SplitView Control?

I make a similar solution of SplitView like in a Microsoft Sample NavigationMenu
So i've got a question. How can i implement a LoginPage in project like this? I don't want to make loginPage with SplitView. I've tried to make splitview closed if my AppFrame is LoginPage, but seems like that solution is too awful.
In xaml you can overlay controls.
Instead of having a login page, have a login control which overlays on top of everything when the user is invalidated.
e.g. xaml
<Grid>
<LoginControl />
<SplitView />
</Grid>