How to log in to Facebook in Xamarin.Forms

UPDATE (10/24/17): While this way of doing things was okay a few years ago, I now strongly advocate for using native UI for doing authentication, as opposed to the webview method shown here. Auth0 is a great way to accomplish native UI login for your apps, using a wide variety of identity providers: https://auth0.com/docs/quickstart/native/xamarin EDIT: … Read more

Adding a button to the title bar Xamarin Forms

Use ToolbarItem from YourPage.xaml.cs: ToolbarItems.Add(new ToolbarItem(“Search”, “search.png”,() => { //logic code goes here })); In Xaml: <ContentPage.ToolbarItems> <ToolbarItem Icon=”search.png” Text=”Search” Clicked=”Search_Clicked”/> </ContentPage.ToolbarItems> Update Xamarin.Forms introduced TitleView in 3.2.0 that you can customize title of the navigation. <ContentPage xmlns=”http://xamarin.com/schemas/2014/forms” xmlns:x=”http://schemas.microsoft.com/winfx/2009/xaml” x:Class=”TestPage”> <NavigationPage.TitleView> <Button … /> </NavigationPage.TitleView> … </ContentPage>

How to generate an .apk file from Xamarin.Forms Project using Visual Studio?

When using Visual Studio 2015 Update 3 with the latest Xamarin tools (which is v4.2.2.6 when writing this answer), right click your Android project and select “Archive…” as described here: https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_1_-_preparing_an_application_for_release/#Compile This will open the Archive Manager and begins the process of archiving the App bundle. When the archiving is finished, you can click on … Read more

How to create click event on label in xamarin forms dynamically

For people who prefer to use XAML and who like to bind Command directly to the ViewModel, you can use this: <Label HorizontalOptions=”Center” TextColor=”Blue” FontSize=”20″ Text=”Forgot Password?”> <Label.GestureRecognizers> <TapGestureRecognizer Command=”{Binding ForgotPasswordCommand}” /> </Label.GestureRecognizers> </Label> And then in your ViewModel, you’ll just assign the command to your function: public ICommand ForgotPasswordCommand => new Command(OnForgotPassword); And then … Read more

Remove ios, windows8, and wp8 from Xamarin Forms PCL – nuget 3.0 opt-into error?

The solution that worked for me: Uninstall Xamarin.Forms: Right Click Solution -> Manage NuGet Packages -> Uninstall Xamarin.Forms -> Restart VS Then remove build platforms: Right Click Solution -> Properties -> Build -> under Targeting select Change -> Remove platform(s) -> Restart VS Reinstall Xamarin.Forms: Manage NuGet packages -> Search for Xamarin.Forms -> Install -> … Read more

Xamarin Forms StackLayout: How to set width / height of children to percentages

StackLayout doesn’t go very well with varying heights in this scenario. The Xamarin Forms engines isn’t as well rounded as the WPF engine at this point. Basically you have to go <Grid> <Grid.RowDefinitions> <RowDefinition Height=”7*” /> <RowDefinition Height=”3*” /> </Grid.RowDefinitions> <Entry Grid.Row=”0″ VerticalOptions=”Fill”></Entry> <Button Grid.Row=”1″ VerticalOptions=”Fill”>Click me</Button> </Grid> Also as a side note, only Grids … Read more