I'm using Xamarin Forms Shell. On one of my <ShellContent> items in my <TabBar>, I just want to open a browser that navigates to a certain URL. I don't have a need to set the ContentTemplate.
It appears that with the <MenuItem> you can set a Command but I don't have the ability to use MenuItem in <TabBar>. Any ideas on how I could achieve this with ShellContent?
<ShellContent
Title="Open Browser"
Icon="browser.png"
Style="{StaticResource DefaultShell}"
???=??? />
You can't use MenuItem in Tabbar. Menuitem can be optionally added to the flyout instead of Tabbar.
I just want to open a browser that navigates to a certain URL.
You still need to set the ContentTemplate with a Page :
<Tab Title="browser" Icon="browser.png">
<ShellContent ContentTemplate="{DataTemplate local:BrowserPage}"/>
</Tab>
Then in that page, navigates to a certain URL:
public BrowserPage()
{
InitializeComponent();
Launcher.OpenAsync("https://www.xamarin.com");
}
Or use a WebView to load the url:
<ContentPage.Content>
<StackLayout>
<WebView HeightRequest="1000" WidthRequest="1000" Source="https://www.xamarin.com"/>
</StackLayout>
</ContentPage.Content>
I uploaded my sample project here and you can check.
Related
I'm trying to set tabs in my whole application.
I created a Tabbed page like this :
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:LogiStock.UI.Base.Views"
x:Class="Views.TabbedPage1" >
<!--Pages can be added as references or inline-->
<views:HomePage x:Name="Test" Title="AA"/>
I can navigate on other page from my HomePage but when I do that, my TabbedPage go away.
How can I keep the navigation inside my tab ?
Im using Xamarin 4.4 and Prism 7.2
The only change you need to do is something like:
<NavigationPage Title="AA" IconImageSource="icon.png">
<x:Arguments>
<views:HomePage x:Name="Test" />
</x:Arguments>
</NavigationPage
And then you can push pages to this navigation stack :)
I created xamarin forms project of a shell template. Now I need to add the reference to my page. Like
<TabBar>
<Tab Title="Shop" Icon="shop.png">
<ShellContent ContentTemplate="{DataTemplate views:ExplorePage}"/>
</Tab>
</TabBar>
I created my page in child folder of views
I need to give the reference in ContentTemplate. How can I give it?
Add a reference xmlns:Dashboard="clr-namespace:UI.Mobile.Views.Dashboard" after the by using reference tag name we can use like <ShellContent ContentTemplate="{DataTemplate Dashboard:PartnerDashboard}" />
I am using Shell Tabbed Page, and it's working fine. But when I navigate to a new Page using
Navigation.PushAsync(new SecondPage());
Then inside the Second Page Shell Tabbed also showing, so I need to hide this shell from this page.
How to do this?
From Sheel backend cs page I can hide this,I also try with Messaging Center to hide this but its not working.
In your page just add:
Shell.TabBarIsVisible="False"
Here is a sample:
ContentPage 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"
mc:Ignorable="d"
Shell.TabBarIsVisible="False"
x:Class="Sample.MySamplePage"
Title="TitleTest">
<StackLayout Spacing="20" Padding="15">
<Label Text="Hello Xamarin"/>
</StackLayout>
</ContentPage>
In Xamarin Forms, I have used TabbedPage in the past to make tabs, and every tab will be loaded at once, so when you transition to one tab to another, it's already loaded.
Now in a new app, I'm trying out the new Shell in Xamarin 4.0. Two of my tabs have a web browser in it, but it doesn't start trying to load the page until after you have clicked into the tab. Is it possible to have all the tabs in a shell load at once?
I'm posting an answer to the actual question I asked, however, please see the disclaimer at the bottom.
Xamrin Forms 4.0 preview, to eager load pages use this code:
<ShellSection x:Name="SpotlightShellSection" Title="Spotlight" Icon="tab_feed.png">
<ShellContent Title="Stats" >
<local:StatsPage/>
</ShellContent>
<ShellContent Title="Upcoming" >
<local:UpcomingPage/>
</ShellContent>
<ShellContent Title="ByMonth" >
<local:ByMonthPage/>
</ShellContent>
<ShellContent Title="Stats2" >
<local:StatsPage/>
</ShellContent>
</ShellSection>
To Lazy load, use code like this:
<ShellSection x:Name="SpotlightShellSection" Title="Spotlight" Icon="tab_feed.png">
<ShellContent Title="Stats" Content="" ContentTemplate="{DataTemplate local:Spotlight.StatsPage}" />
<ShellContent Title="Upcoming" ContentTemplate="{DataTemplate local:Spotlight.UpcomingPage}" />
<ShellContent ContentTemplate="{DataTemplate local:Spotlight.ByMonthPage}" />
</ShellSection>
Warning, which is my problem, the content of WebViews will not necessarily stay loaded in android only.In iOS the webviews keep their content as expected.
Can you tell me how can I add toolbar item in a tabbed page in xamarin from.
thanks
<TabbedPage.ToolbarItems>
<ToolbarItem Name="MenuItem1" Order="Primary" Icon="Microsoft.png" Text="Item 1" Priority="0" />
<ToolbarItem Name="MenuItem2" Order="Primary" Icon="Xamarin.png" Text="Item 2" Priority="1" />
</TabbedPage.ToolbarItems>
Re: Xamarin Forms Toolbar