How to add toolbar item in TabbedPage in Xamarin Form - xamarin

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

Related

Navigate inside a TabbedPage and keep the TabbedPage as Host

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 :)

Xamarin Forms ShellContent Open Browser

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.

How to hide Shell Tabbed from another Page in Xamarin Forms?

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>

Xamarin Forms XAML Image control has quit working

I have a working app that displays images. I started a new app and copied the code but this new app does not display images. Puzzled, I have tried many, many things to debug it. I eventually made a plain vanilla new project with only an Image control. As usual, I added the picture to the project using Add Existing Item. I confirmed that the image is there. It does not display the image. I noticed something different in Solution Explorer. Under the Solution, the first project has Dependencies listed under it. This is new. My previous apps have never had that. Now every new project I create has it. I also noticed that the Properties of the image was Build Action of None. I tried changing it to Content but that did not help. At this point, I am baffled and stuck. Did something change in Visual Studio? Here is the image test XAML.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:ImageTest"
x:Class="ImageTest.MainPage">
<StackLayout>
<!-- Place new controls here -->
<Image Source="gr8oz.png" />
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage>
As I said, I have a working app that has been released. I copied this code into a new app and it does not work. In my investigation, I have found that the Image control does not work for me anymore.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:OFamV2"
Style="{StaticResource MyContentPage}"
x:Class="OFamV2.MainPage"
Title="Main Menus">
<ScrollView>
<StackLayout>
<Button x:Name="TreeButton"
Text="Don and Iola Osborne"
VerticalOptions="Start"
Style="{StaticResource MyButtons}"
Clicked="TreeButton_Clicked" />
<Button x:Name="IndianNamesButton"
Text="Indian Names"
VerticalOptions="Start"
Style="{StaticResource MyButtons}"
Clicked="IndianNamesButton_Clicked" />
<Button x:Name="NextPageButton"
Text="Indian Potpourri"
VerticalOptions="Start"
Style="{StaticResource MyButtons}"
Clicked="NextPageButton_Clicked" />
<Button x:Name="OldPhotos"
Text="Old Photos"
VerticalOptions="Start"
Style="{StaticResource MyButtons}"
Clicked="OldPhotos_Clicked" />
<Button x:Name="ReunionButton"
Text="Family Reunion"
VerticalOptions="Start"
Style="{StaticResource MyButtons}"
Clicked="ReunionButton_Clicked"
/>
<StackLayout Orientation="Horizontal">
<Image
Source="Photos/gr8oz.png"
Style="{StaticResource MyImage}"
Margin="0,30,0,0"
Aspect="AspectFit"
HorizontalOptions="End"
/>
<Image
Source = "Photos/logo.bmp"
Style="{StaticResource MyImage}"
Margin="150,0,0,0"
HeightRequest="200"
WidthRequest="200"
HorizontalOptions="End"/>
</StackLayout>
</StackLayout>
</ScrollView>
</ContentPage>
I have searched and read everything that I can find (and yes, I have read the Microsoft doc about the Image class).
I am also curious why Dependencies suddenly appeared in the Shared Project folder. This is new too. How do I resolve them? See screenshot.
Dependencies under OFamV2.
I uninstalled Visual Studio, deleted the folder, reinstalled Visual Studio Community 2017 Version 15.8.8 and the problem is still there, even with a new project.
For Options, I select Cross Platform/ Mobile App/ Platform: Android and UWP/Code Sharing: .Net Standard.
Set image show you can see here , i think you have used that.
So reload your project,and rebuild it,you can try this.
More info:
Here is a similar disscussion about image show.
Suggest that better not copy code from other project about view,they may result some problems where you do not know.

No property, bindable property, or event found for 'HeightRequest' for Button

I have an IOS Application with embedded Xamarin Forms. I created a simple view with buttons and want to set the height of these buttons depending on the platform. This is my code:
<Button Text="{Binding SendFeedbackButtonText}"
Command="{Binding SendEarlyFeedbackCommand}"
HorizontalOptions="FillAndExpand"
Margin="3,0,3,0" >
<Button.Effects>
<effects:PrimaryButtonEffect />
</Button.Effects>
<Button.HeightRequest>
<OnPlatform x:TypeArguments="x:Double">
<On Platform="iOS" Value="37"/>
</OnPlatform>
</Button.HeightRequest>
</Button>
But this gives me the following error in build:
No property, bindable property, or event found for 'HeightRequest', or mismatching type between value and property.
When I set HeightRequest fix in the button tag it works.
Xamarin.Forms version: 2.5.0.121934
Also I created a new blank App with Xamarin.Forms and .net standard 2.0 to try this out. It works as long as you don't have the XamlCompilation Attribute set:
[XamlCompilation(XamlCompilationOptions.Compile)]
You can find the project here: https://github.com/NPadrutt/FormsButtonIssueTestProject
What am I doing wrong?
Depending on your version of Forms try switching it to this instead
<Button.HeightRequest>
<OnPlatform x:TypeArguments="x:Double" iOS="37"/>
</Button.HeightRequest>
or
<Button.HeightRequest>
<OnPlatform x:TypeArguments="x:Double">
<On Platform="iOS">37</On>
</OnPlatform>
</Button.HeightRequest>

Resources