In Android, because the tab bar is at top, I don't need both title bar and tab bar to say which tab you're on.
This will hide the title bar for both platforms:
<TabbedPage>
<NavigationPage Title="Page 1">
<x:Arguments>
<local:Page1 NavigationPage.HasNavigationBar="false"/>
</x:Arguments>
</NavigationPage>
</TabbedPage>
try this:
<NavigationPage Title="Page 1">
<x:Arguments>
<Page>
<NavigationPage.HasNavigationBar>
<OnPlatform x:TypeArguments="x:Boolean">
<On Platform="Android" Value="False"></On>
</OnPlatform>
</NavigationPage.HasNavigationBar>
</Page>
</x:Arguments>
</NavigationPage>
Related
I added a toolbar item of name refresh in tabbed page, below is the code of the tabbed page
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Xapp;assembly=Xapp"
mc:Ignorable="d"
x:Class="Xapp.HomePage">
<TabbedPage.ToolbarItems>
<ToolbarItem x:Name="Refresh" Text="Refresh" />
</TabbedPage.ToolbarItems>
<TabbedPage.Children>
<NavigationPage Title="report">
<x:Arguments>
<local:ReportPage>
<StackLayout>
<Label Text="In:" HorizontalOptions="FillAndExpand" />
<Label Text="{Binding CountIn}" FontSize="Medium" FontAttributes="Bold" />
<Label Text="Out:" HorizontalOptions="FillAndExpand" />
<Label Text="{Binding CountOut}" FontSize="Medium" FontAttributes="Bold" />
<Label Text="Date:" HorizontalOptions="FillAndExpand" />
<Label Text="{Binding createdon}" FontSize="Medium" FontAttributes="Bold" />
</StackLayout>
</local:ReportPage>
</x:Arguments>
</NavigationPage>
<NavigationPage Title="history">
<x:Arguments>
<local:HistoryPage />
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>
the problem is the refresh appears two times in the toolbar as shown in the image below:
If the MainPage of App is a TabbedPage . You don't need to set it as NavigationPage . in App.
Modify the code in App.Xaml.CS
public App()
{
InitializeComponent();
MainPage = new HomePage();
}
Update
It is not a good design to navigate from a ContentPage to TabbedPage .
So modify the code to
App.Current.MainPage = new HomePage();
instead of page.Navigation.PushAsync(new HomePage());
Is there any way to set the width of MasterDetailPage.Master in Xamarin? I want to decrease the width of the Menu Drawer. Hope you can help me with this code:
<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="DemoApp.MenuPage"
xmlns:local="clr-namespace:DemoApp.Views"
MasterBehavior="Popover"
NavigationPage.HasNavigationBar="False"
NavigationPage.HasBackButton="False">
<MasterDetailPage.Master>
<ContentPage Title="MenuPage">
<ContentPage.Content>
<StackLayout VerticalOptions="Start">
<Button Text="Home"/>
<Button Text="Login" Clicked="Login_Clicked"/>
<Button Text="Logout"/>
<Button Text="Exit"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
<x:Arguments>
<local:Login/>
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>
Use custom renderer.
https://forums.xamarin.com/discussion/comment/62894/#Comment_62894
Or use this solution
How to set width for MasterDetailPage in xamarin forms
My code showing icon only for iOS application. How can I add tab icon in NavigationPage.Icon for android too, xaml code
<NavigationPage Title="DairyTabPage">
<NavigationPage.Icon>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS" Value="icon_tab"/>
</OnPlatform>
</NavigationPage.Icon>
<x:Arguments>
<local:HomePage />
</x:Arguments>
</NavigationPage>
<NavigationPage Title="DairyTabPage" Icon="icon_tab">
<x:Arguments>
<local:HomePage />
</x:Arguments>
</NavigationPage>
This is what worked for me in case the other answer doesn't work for you:
<NavigationPage Title="Title">
<NavigationPage.Icon>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS" Value="tab_feed.png"/>
<On Platform="Android" Value="tab_feed"/>
</OnPlatform>
</NavigationPage.Icon>
<x:Arguments>
<views:ItemsPage />
</x:Arguments>
</NavigationPage>
Where I have put "tab_feed.png" into /Resources/drawable/tab_feed.png and included in the .Android project and rebuilt it so it regenerated the Resource.designer.cs file.
How do you change the background from a Advanced ApplicationBar? I tried this but it stays black.
<Sh:AdvancedApplicationBar Background="Gray">
<Grid>
<Sh:AdvancedApplicationBarIconButton Text="edit"
IconUri="/Assets/ActionBarButtons/btn_actionbar_edit.png"
Command="{Binding EditCommand}"
VerticalAlignment="Bottom" />
</Grid>
</Sh:AdvancedApplicationBar>
replace <Sh:AdvancedApplicationBar Background="Gray"> by <Sh:AdvancedApplicationBar BackgroundColor="Gray">
I found it out, it is a wrapper arround the normal Appbar so you need to do this:
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar BackgroundColor="Gray"
Opacity="0.5" />
</phone:PhoneApplicationPage.ApplicationBar>
I want to place Pivot inside Panorama and disable horizontal flick gestures for Pivot.
If I set IsLocked="True" for Pivot, when I make horizontal flick,
Panorama item is not changing.
If i set IsHitTestVisible="False" for
Pivot, I cant tap anything inside Pivot.
How can make this:
Pivot can "sense" Tap and vertical flick gestures
Panorama can "sense" horisontal flick gestures
This is not recommended behavior for Windows phone platform. Putting a Pivot inside a Panorama doesn't make sense at all and goes against WP design guidelines. Cant you have the same functionality with Panorama control alone?
Use PanoramaItems as you use PivotItems, if you want vertical scrolling use a ScrollView instead. Doing like you mentioned might make your app not certifiable.
<Grid x:Name="LayoutRoot">
<phone:Panorama Title="my application">
<!--Panorama item one-->
<phone:PanoramaItem Header="item1">
<Grid>
<ScrollViewer Height="480">
<StackPanel>
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
</StackPanel>
</ScrollViewer>
</Grid>
</phone:PanoramaItem>
<!--Panorama item two-->
<phone:PanoramaItem Header="item2">
<Grid/>
</phone:PanoramaItem>
<phone:PanoramaItem Header="item3">
<Grid/>
</phone:PanoramaItem>
</phone:Panorama>
</Grid>
With the above Panorama Page you can have horizontal scrolling among PanoramaItems and Vertical Scrolling for the content of the PanoramaItem