本文整理汇总了C#中Xamarin.Forms.Page.DisplayAlert方法的典型用法代码示例。如果您正苦于以下问题:C# Page.DisplayAlert方法的具体用法?C# Page.DisplayAlert怎么用?C# Page.DisplayAlert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xamarin.Forms.Page
的用法示例。
在下文中一共展示了Page.DisplayAlert方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GuardarUser
private async void GuardarUser()
{
_user.Avatar = "";
var page = new Page();
try
{
IsBusy = true;
var r = await _servicio.AddUsuario(_user);
if (r != null)
{
await page.DisplayAlert(Strings.UserCreatedTitle,
Strings.UserCreatedText, Strings.Ok);
await _navigator.PushModalAsync<LoginViewModel>();
}
else
{
var a = "";
}
}
catch (Exception e)
{
await page.DisplayAlert(Strings.Error, Strings.UserAlreadyText, Strings.Ok);
}
finally
{
IsBusy = false;
}
}
示例2: IniciarSesion
private async void IniciarSesion()
{
var page = new Page();
try
{
IsBusy = true;
var us = await _servicio.ValidarUsuario(_login);
if (us != null)
{
await _navigator.PopToRootAsync();
await _navigator.PushAsync<ContactosViewModel>(viewModel =>
{
Titulo = "Inicio de sesión";
});
}
else
{
var xx = ""; //para comprobar que se haga bien.
}
//TODO: aquí navegaríamos a la pantalla principal o daríamos error
await page.DisplayAlert(Strings.Error, Strings.UserDoesNotExist, Strings.Ok);
}
catch (Exception e)
{
await page.DisplayAlert(Strings.Error, e.Message, Strings.Ok);
}
finally
{
IsBusy = false;
}
}
示例3: FundsTransferViewModel
public FundsTransferViewModel (INavigation navigation, Page currentPage)
{
Navigation = navigation;
CancelCommand = new Command(async () => await Navigation.PopAsync());
TransferCommand = new Command(async () => await currentPage.DisplayAlert("Transfer", "Success", "Ok"));
}
示例4: Show
public async void Show(Page callingPage)
{
RateFeedbackResult result = RateFeedbackResult.None;
await Task.Delay(1);
// var rateAnswer = await callingPage.DisplayAlert(RateMessageTitle, RateMessage, RateButtonLabel, RateCancelLabel);
callingPage.DisplayAlert(RateMessageTitle, RateMessage, RateButtonLabel, RateCancelLabel).ContinueWith(r =>
{
if (r.Result)
{
IAppRater rater = DependencyService.Get<IAppRater>();
rater.RateApp(this.AppId);
result = RateFeedbackResult.Rate;
this.RateFeedbackCompleted(callingPage, new RateFeedbackEventArgs(result));
}
else
{
// var feedbackAnswer = await callingPage.DisplayAlert(FeebackMessageTitle, FeebackMessage, FeebackButtonLabel, FeebackCancelLabel);
callingPage.DisplayAlert(FeebackMessageTitle, FeebackMessage, FeebackButtonLabel, FeebackCancelLabel).ContinueWith(f =>
{
if (f.Result)
{
IEmailComposer emailer = DependencyService.Get<IEmailComposer>();
emailer.SendEmail(FeedbackEmail, FeedbackSubject, FeedbackBody);
result = RateFeedbackResult.Feedback;
this.RateFeedbackCompleted(callingPage, new RateFeedbackEventArgs(result));
}
else
{
this.RateFeedbackCompleted(callingPage, new RateFeedbackEventArgs(result));
}
}, TaskScheduler.FromCurrentSynchronizationContext()
);
}
}, TaskScheduler.FromCurrentSynchronizationContext()
);
}
示例5: ListenerBindView
public ListenerBindView(int defaultPort, Page parentPage)
{
_parentPage = parentPage;
var portEntry = new Entry()
{
Placeholder = "Listen Port",
Text = defaultPort.ToString(),
HorizontalOptions = LayoutOptions.Start
};
var listenButton = new Button
{
Text = "Start Listening",
};
// listen / stop listening
listenButton.Clicked += async (sender, args) =>
{
// if not already listening
if (!_listening)
{
if (StartListeningTapped == null) return;
// check valid port
var port = -1;
var isNumeric = Int32.TryParse(portEntry.Text, out port);
if (!isNumeric || ((port < 1001 || port > 65535)))
{
await _parentPage.DisplayAlert("Invalid Port", "Port must be numeric value between 1001 & 65535", "My bad");
return;
}
// callback
if (await StartListeningTapped(port))
{
_listening = true;
listenButton.Text = "Stop Listening";
};
}
else
{
if (StopListeningTapped == null) return;
// callback
await StopListeningTapped();
_listening = false;
listenButton.Text = "Start Listening";
}
};
Content = new StackLayout
{
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.FillAndExpand,
Children =
{
new Label {
Text = "Listen port:",
VerticalOptions = LayoutOptions.CenterAndExpand
},
portEntry,
listenButton
}
};
}
示例6: InformUser
public static void InformUser(Page page, string message)
{
page.DisplayAlert ("Information", message, "OK");
}
示例7: WarnUser
public static void WarnUser(Page page, string warning)
{
page.DisplayAlert ("Warning", warning, "OK");
}
示例8: ClientConnectView
public ClientConnectView(string defaultAddress, int defaultPort, Page parentPage)
{
_parentPage = parentPage;
var addressEntry = new Entry
{
Placeholder = "Address",
Text = defaultAddress,
HorizontalOptions = LayoutOptions.StartAndExpand
};
var portEntry = new Entry()
{
Placeholder = "Port",
Text = defaultPort.ToString(),
HorizontalOptions = LayoutOptions.Start
};
var connectButton = new Button
{
Text = "Connect",
};
// connect / disconnect
connectButton.Clicked += async (sender, args) =>
{
// if not already connected
if (!_connected)
{
if (ConnectTapped == null) return;
var address = addressEntry.Text;
// check valid port
var port = -1;
var isNumeric = Int32.TryParse(portEntry.Text, out port);
if (!isNumeric || ((port < 1001 || port > 65535)))
{
await _parentPage.DisplayAlert("Invalid Port", "Port must be numeric value between 1001 & 65535", "My bad");
return;
}
// callback
if (await ConnectTapped(address, port))
{
_connected = true;
connectButton.Text = "Disconnect";
};
}
else
{
if (DisconnectTapped == null) return;
// callback
await DisconnectTapped();
_connected = false;
connectButton.Text = "Start Listening";
}
};
Content = new StackLayout
{
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.FillAndExpand,
Children =
{
new Label {
Text = "Connect to:",
VerticalOptions = LayoutOptions.CenterAndExpand
},
addressEntry,
portEntry,
connectButton
}
};
}