public static void Show(Panel container, AlertDialogParameters parameters) { var dlg = new AlertDialog(); dlg.ApplyAlertDialogParameters(parameters); container.Children.Add(dlg); dlg.AgreeButton.Click += (sender, e) => { try { container.Children.Remove(dlg); } catch { throw new AuraException <AlertDialog>("The Panel does not exist"); } }; dlg.CancelButton.Click += (sender, e) => { try { container.Children.Remove(dlg); } catch { throw new AuraException <AlertDialog>("The Panel does not exist"); } }; }
private void InitializeComponent() { AvaloniaXamlLoader.Load(this); container1 = this.Find <Grid>("container1"); var dlg_param = new DialogParameters("Hey!", "Are you ready?", "Yes", DoNothing); var alt_param = new AlertDialogParameters(dlg_param, "No", DoNothing, true); dlg_btn = this.Find <Button>("dlg"); dlg_btn.Click += (sender, e) => { Dialog.Show(container1, dlg_param); }; dlg_ios_btn = this.Find <Button>("ios_dlg"); dlg_ios_btn.Click += (sender, e) => { CupertinoDialog.Show(container1, dlg_param); }; alt_dlg_btn = this.Find <Button>("alt_dlg"); alt_dlg_btn.Click += (sender, e) => { AlertDialog.Show(container1, alt_param); }; alt_dlg_ios_btn = this.Find <Button>("ios_altdlg"); alt_dlg_ios_btn.Click += (sender, e) => { CupertinoAlertDialog.Show(container1, alt_param); }; }
public void ApplyAlertDialogParameters(AlertDialogParameters dialogParameters) { this.Header = dialogParameters.Header; this.Content = dialogParameters.Content; this.AgreeButtonContent = dialogParameters.AgreeContentButton; this.CancelButtonContent = dialogParameters.CancelContentButton; this.AgreeButton.Click += (sender, e) => { dialogParameters.AgreeClick.Invoke(); }; this.CancelButton.Click += (sender, e) => { dialogParameters.CancelClick.Invoke(); }; }