Skip to content

Instantly share code, notes, and snippets.

@reuniware
Created March 6, 2020 13:24
Show Gist options
  • Select an option

  • Save reuniware/8af23795caab9506d993cfea020c513c to your computer and use it in GitHub Desktop.

Select an option

Save reuniware/8af23795caab9506d993cfea020c513c to your computer and use it in GitHub Desktop.
Xamarin : Show messages on button click
<?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:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="XamarinFormsTest01.MainPage">
<StackLayout>
<!-- Place new controls here -->
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Button x:Name="BtnStart" Text="start" Pressed="BtnStart_Pressed" />
<Button x:Name="BtnStop" Text="stop" />
</StackLayout>
</ContentPage>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace XamarinFormsTest01
{
// Learn more about making custom code visible in the Xamarin.Forms previewer
// by visiting https://aka.ms/xamarinforms-previewer
[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void BtnStart_Pressed(object sender, EventArgs e)
{
showmsg();
}
private async void showmsg()
{
var action = await DisplayActionSheet("Select an action", "OK", "CANCEL", "Action 1", "Action 2", "Action 3");
await DisplayAlert("Alert", "action = " + action, "OK");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment