Reputation: 1660
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}"
???=??? />
Upvotes: 0
Views: 598
Reputation: 15816
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.
Upvotes: 2