I have an image of the name logout.png that I try to display in a Tabbedpage. But it shows me a big grey circle. And when I put it on another page, it appears without problem
<NavigationPage Title="{Static properties:Resources.LabelLogout}" Icon="logout.png">
<x:Arguments>
<views:LogoutPage/>
</x:Arguments>
</NavigationPage>
You should use IconImageSource="logout.png" to set Icon for Tabbar , not Icon="logout.png" . Have a look at follow sample code :
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TabbedPageWithNavigationPage;assembly=TabbedPageWithNavigationPage"
x:Class="TabbedPageWithNavigationPage.MainPage">
<local:TodayPage />
<NavigationPage Title="Schedule" IconImageSource="schedule.png">
<x:Arguments>
<local:SchedulePage />
</x:Arguments>
</NavigationPage>
</TabbedPage>
Here is an official sample project for reference .
Related
I am showing bottom tabs in Xamarin forms using TabbedPage. For that I have added the child pages (Page1,Page2,Page3) programatically to the TabbedPage. First I have login screen, onclick of Login button it will redirect to tabbed page and will show all the three tabs at the bottom.
There are other pages(Page4,Page5) that we are not showing as child pages in tabbed page. But as per the requirement when user opens page4 or page5 the bottom tab bar should show.
Overall what I mean is the bottom tab bar should show to all the screens in the application even though some of the screens are not the children of the TabbedPage.
Could anyone please tell me how to achieve this task. Thanks in advance.
You can wrap TabbedPage's children within NavigationPages, so that when you navigate to another page from one of those tabs they will still appear:
<?xml version="1.0" encoding="UTF-8" ?>
<TabbedPage
x:Class="SampleTabbedPage.Views.MainPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:SampleTabbedPage.Views;assembly=SampleTabbedPage"
NavigationPage.HasNavigationBar="False">
<!-- Page 1 -->
<NavigationPage IconImageSource="ic_home">
<x:Arguments>
<views:HomePage />
</x:Arguments>
</NavigationPage>
<!-- Page 2 -->
<NavigationPage IconImageSource="ic_profile">
<x:Arguments>
<views:ProfilePage />
</x:Arguments>
</NavigationPage>
</TabbedPage>
In code behind:
var tabbedPage = new TabbedPage();
tabbedPage.Children.Add(new NavigationPage(new Page1()));
tabbedPage.Children.Add(new NavigationPage(new Page2()));
tabbedPage.Children.Add(new NavigationPage(new Page3()));
Then you can just call from one of the child pages:
await Navigation.PushAsync(new YourNewPage());
The font that I have is too big for the amount of words that I would like to display. Does anyone have any suggestions as to how I can change the font size. I would prefer to be able to do it in the shared code but if it needs a custom renderer then can someone show me how this can be done?
So, if you are using Xamarin.Forms 3.2.0 or above, you can use TitleView property like this:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Xamarin.Forms.Controls.GalleryPages.TitleView">
<NavigationPage.TitleView>
<Label Text="This is my Title" FontSize="12" TextColor="White" />
</NavigationPage.TitleView>
<!-- YOUR CONTENT HERE-->
</ContentPage>
I want to bring a search tab on top of a tabbed page in Xamarin Forms. This is the UI I want to implement.
As you can see a search bar on top of tab vendor name and product/service. I don't know how to implement it. I have tried this code
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:RestaurantApp"
x:Class="RestaurantApp.SearchTabbedPage"
NavigationPage.HasNavigationBar="False">
<ContentPage>
<StackLayout>
<StackLayout Orientation="Horizontal"
HorizontalOptions="FillAndExpand"
Padding="5">
<Label TextColor="#606060" FontSize="Large" Text="EXPLORE"
HorizontalOptions="CenterAndExpand"/>
</StackLayout>
<BoxView Color="#E0E0E0" WidthRequest ="80" HeightRequest="1"/>
<Frame CornerRadius="10" Padding="0" OutlineColor="DarkGray" HasShadow="True" HorizontalOptions="Fill" Margin="10,0,10,0" VerticalOptions="Center">
<pages:searchTab x:Name="searchBar" Placeholder="Search" PlaceholderColor="Black" TextColor="Black" HorizontalOptions="FillAndExpand" VerticalOptions="Center" />
</Frame>
</StackLayout>
</ContentPage>
<TabbedPage.Children>
<NavigationPage Title="VENDOR NAME">
<x:Arguments>
<pages:TabbedPageExampleTab1 />
</x:Arguments>
</NavigationPage>
<NavigationPage Title="PRODUCT/SERVICE">
<x:Arguments>
<pages:TabbedPageExampleTab2 />
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>
But it created one more tab. I don't know how to implement this. And I'm not getting any solution for this. Any suggestions?
Note:
I have the code for navigation tab title and bottom navigation bar. And I want to keep them common for both the tabbed page. So it has to be implemented in the same way as the search tab.
You can't add a (Content)Page inside a (Tabbed)Page. You have to change your layout, so you have a ContentPage and inside of it, you add a Label (Header "Explore"), SearchBar, Custom Tabs (not TabbedPage) with Lists...
For Tabs you can use either your custom layout build with buttons which change visibility of the Lists, or you can use some fancier existing solutions like TabView from Telerik, or Segmented Bar Control by Rendy.
UI Tips: From UI perspective your mockup could be a little better if you have one TabbedPage with 4 Children:
Near Me
Search - if the user clicks on Add, you can dynamically change the Cart
Cart
Account
If you have the newest Xamarin Forms nuget package (from 3.1), you can add tabs on the bottom.
TabbedPage can accept content page as only children.
If you want to add search view on top of navigation bar this article can help you https://www.linkedin.com/pulse/xamarin-forms-contentpage-searchbar-navigation-bar-vipin-mathews
I'm following this guide (https://15mgm15.ghost.io/2018/06/06/bottom-tabbed-page-for-xamarin-forms-android/) but I cant figure out how to add the pages I've added to the project.
I need to add something here in order for the app to understand which pages are to be shown:
<TabbedPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:bottom"
x:Class="bottom.MainPage">
<TabbedPage.Children>
<ContentPage Title="Page 1" Icon="death_star.png"/>
<ContentPage Title="Page 2" Icon="green_star.png"/>
<ContentPage Title="Page 3" Icon="star.png"/>
</TabbedPage.Children>
</TabbedPage>
Right now, It is only showing the tabbed page since it doesnt know which pages to get info from.
Strongly recommend that you read the official docs: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/tabbed-page
If you are attempting to add an existing XAML page to the tabbed page, you would need to replace each ContentPage element in your code above with the pages you want.
eg if you had a page called "MyTestPage"
<TabbedPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:bottom"
x:Class="bottom.MainPage">
<TabbedPage.Children>
<MyTestPage Title="Page 1" Icon="death_star.png"/>
<ContentPage Title="Page 2" Icon="green_star.png"/>
<ContentPage Title="Page 3" Icon="star.png"/>
</TabbedPage.Children>
In my xamarin app,I want to add a search bar on top of the page in my tabbed page.
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Sample.Mobile.Test">
<StackLayout>
<SearchBar></SearchBar>
</StackLayout>
<TabbedPage.Children>
<ContentPage x:Name="tab1" Title="Home">
</ContentPage>
</TabbedPage.Children>
</TabbedPage>
You can use follow this link for the Search bar Implementation
https://developer.xamarin.com/api/type/Xamarin.Forms.SearchBar/