I am new in C# and Xamarin I am creating a Xamarin Forms App and want o create an button that can handle different task from different platform (i.e. iOS & Android).
Suppose I want to use a binding binding library (android binding Library and other is iOS Binding library). On a button click in Xamarin Forms App I want to execute platform specific library method for example suppose in Android Binding library there is a method void ShowAndroidContent();
and on the other iOS Binding library there is a method -(void)ShowiOSContent;
so On the button click if device is Android ShowAndroidContent();
should be execute and if iOS then ShowiOSContent();
should be execute.
My Solution Name is XamarinFormsAppDemo
TestXamarinFormAppPage.xaml Code is:-
<?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:TestXamarinFormApp" x:Class="TestXamarinFormApp.TestXamarinFormAppPage">
<AbsoluteLayout>
<StackLayout AbsoluteLayout.LayoutBounds="0,1,1,0.1"
AbsoluteLayout.LayoutFlags="All"
BackgroundColor="Transparent">
<Button Text="Click Me !" Clicked="OnButtonClicked"></Button>
</StackLayout>
</AbsoluteLayout>
TestXamarinFormAppPage.xaml.cs Code is:-
using System;
using Xamarin.Forms;
using System.Runtime.CompilerServices;
using System.ServiceModel.Channels;
namespace TestXamarinFormApp
{
public partial class TestXamarinFormAppPage : ContentPage
{
public TestXamarinFormAppPage ()
{
InitializeComponent ();
}
int count = 0;
public void OnButtonClicked (object sender, EventArgs args)
{
// here if device is Android the button click should be handle from MainActivity.cs in TestXamarinFormApp.Droid part and
// if device is an iOS then this button click should be handle from Main.cs in TestXamarinFormApp.iOS
}
}
}
I'am using Xamarin Studio for it. Can anybody help me to do this. Please help me. Thank you.