• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

Hướng dẫn tạo cảnh báo khi người dùng nhấn vào nút thoát app trên Xamarin Forms

Admin

Well-Known Member
Staff member
Administrator
Chào các bạn, hôm nay tuoitreit.vn xin hướng dẫn các bạn cách tạo cảnh báo khi nhấn nút thoát
Để tạo cảnh báo khi nhấn nút thoát bạn sử dụng code sau nhé
Trong MainPage.xaml
XML:
<Button x:Name="BtnOut" Text="Thoát" Clicked="BtnOut_Clicked"/>
Trong MainPage.xaml.cs
Code:
  private void BtnOut_Clicked(object sender, EventArgs e)
        {
            Device.BeginInvokeOnMainThread(async () =>
            {
                var result = await this.DisplayAlert("Cảnh báo", "Bạn có chắc muốn thoát", "Có", "Không");
                if (result) await this.Navigation.PopAsync();
            });
        }
Chúc bạn thành công!
Mọi sao chép vui lòng ghi rõ nguồn tuoitreit.vn
 

Facebook Comments

Similar threads

New posts New threads New resources

Back
Top