[PopupPage.Xaml.cs]
private async void Button_Clicked(object sender, EventArgs e)
{
await this.DisplaySfPopupAlert("PopupHeader","Popup", null , "Cancel");
}
private async void Button_Clicked_1(object sender, EventArgs e)
{
await this.DisplaySfPopupAlert("PopupHeader", "Popup", "Ok", "Cancel");
}
public async Task<bool> DisplaySfPopupAlert(string title, string message, string acceptText, string cancelText)
{
........
popupLayout.PopupView.AppearanceMode = string.IsNullOrEmpty(acceptText) ? AppearanceMode.OneButton : AppearanceMode.TwoButton;
if (popupLayout.PopupView.AppearanceMode == AppearanceMode.OneButton)
{
DataTemplate declineButtonTemplate = new DataTemplate(() =>
{
StackLayout _stackLayout = new StackLayout();
Button declineButton = new Button();
declineButton.Text = cancelText;
declineButton.BackgroundColor = Color.White;
declineButton.TextColor = Color.Black;
declineButton.HorizontalOptions = LayoutOptions.End;
declineButton.Command = new Command(() => {
PopupAccepted = false;
popupLayout.IsOpen = false;
});
_stackLayout.Children.Add(declineButton);
return _stackLayout;
});
popupLayout.PopupView.FooterTemplate = declineButtonTemplate;
}
else
{
..........
}
.........
} |