display alert, display action sheet

main
syneffort 2 years ago
parent c107d6eac5
commit b394c19b34
  1. 4
      XamarinStudy/XamarinStudy/XamarinStudy/App.xaml.cs
  2. 16
      XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleDisplayAlertActionSheetPage.xaml
  3. 62
      XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleDisplayAlertActionSheetPage.xaml.cs
  4. 3
      XamarinStudy/XamarinStudy/XamarinStudy/XamarinStudy.csproj

@ -47,7 +47,9 @@ namespace XamarinStudy
//MainPage = new SampleAbsoluteLayoutPage();
MainPage = new SampleRelativeLayoutPage();
//MainPage = new SampleRelativeLayoutPage();
MainPage = new SampleDisplayAlertActionSheetPage();
}
protected override void OnStart()

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamarinStudy.Views.SampleDisplayAlertActionSheetPage">
<ContentPage.Content>
<StackLayout>
<Button x:Name="button1" Text="Alert" Clicked="button1_Clicked"/>
<Button x:Name="button2" Text="ChangeText" Clicked="button2_Clicked"/>
<Label x:Name="label1" Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"/>
<Button x:Name="button3" Text="Font Style ActionSheet" Clicked="button3_Clicked"/>
<Button x:Name="button4" Text="Font Size ActionSheet" Clicked="button4_Clicked"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace XamarinStudy.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SampleDisplayAlertActionSheetPage : ContentPage
{
public SampleDisplayAlertActionSheetPage()
{
InitializeComponent();
}
private void button1_Clicked(object sender, EventArgs e)
{
DisplayAlert("Title", "This is alert.", "OK");
}
private async void button2_Clicked(object sender, EventArgs e)
{
var result = await DisplayAlert("Question", "Select result.", "YES", "NO");
if (result)
label1.Text = "YES";
else
label1.Text = "NO";
}
private async void button3_Clicked(object sender, EventArgs e)
{
var result = await DisplayActionSheet("Change font style.", "Cancel", null, "Bold", "Italic", "None");
switch (result)
{
case "Bold":
label1.FontAttributes = FontAttributes.Bold;
break;
case "Italic":
label1.FontAttributes = FontAttributes.Italic;
break;
case "None":
label1.FontAttributes = FontAttributes.None;
break;
default:
break;
}
}
private async void button4_Clicked(object sender, EventArgs e)
{
var result = await DisplayActionSheet("Change font style.", "Cancel", null, "10", "20", "30", "40", "50");
if (result == null)
return;
label1.FontSize = double.Parse(result);
}
}
}

@ -23,6 +23,9 @@
<EmbeddedResource Update="Views\SampleContentPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\SampleDisplayAlertActionSheetPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\SampleElementPage1.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>

Loading…
Cancel
Save