本文整理汇总了C#中ContentDialogButtonClickEventArgs.GetDeferral方法的典型用法代码示例。如果您正苦于以下问题:C# ContentDialogButtonClickEventArgs.GetDeferral方法的具体用法?C# ContentDialogButtonClickEventArgs.GetDeferral怎么用?C# ContentDialogButtonClickEventArgs.GetDeferral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentDialogButtonClickEventArgs
的用法示例。
在下文中一共展示了ContentDialogButtonClickEventArgs.GetDeferral方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContentDialog_PrimaryButtonClick
//Sign in button
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
// Ensure the user name and password fields aren't empty. If a required field
// is empty, set args.Cancel = true to keep the dialog open.
if (string.IsNullOrEmpty(userNameTextBox.Text))
{
args.Cancel = true;
errorTextBlock.Text = "User name is required.";
}
else if (string.IsNullOrEmpty(passwordTextBox.Password))
{
args.Cancel = true;
errorTextBlock.Text = "Password is required.";
}
// If you're performing async operations in the button click handler,
// get a deferral before you await the operation. Then, complete the
// deferral when the async operation is complete.
ContentDialogButtonClickDeferral deferral = args.GetDeferral();
//if (await SomeAsyncSignInOperation())
//{
this.Result = SignInResult.SignInOK;
//}
//else
//{
// this.Result = SignInResult.SignInFail;
//}
deferral.Complete();
}
示例2: ContentDialog_PrimaryButtonClick
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
// Ensure the user name and password fields aren't empty. If a required field
// is empty, set args.Cancel = true to keep the dialog open.
if (string.IsNullOrEmpty(txtUsername.Text))
{
args.Cancel = true;
txtError.Text = "User name is required";
return;
}
else if (string.IsNullOrEmpty(txtPassword.Password))
{
args.Cancel = true;
txtError.Text = "Password is required";
return;
}
// If you're performing async operations in the button click handler,
// get a deferral before you await the operation. Then, complete the
// deferral when the async operation is complete.
ContentDialogButtonClickDeferral deferral = args.GetDeferral();
var rememberMe = chkRememberMe.IsChecked.Value;
if( !await dataAccess.Login(txtUsername.Text, txtPassword.Password, rememberMe) )
{
args.Cancel = true;
txtError.Text = "Login Failed";
}
deferral.Complete();
}
示例3: OkButtonClick
private async void OkButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
// Get the deferral because we need to await the
// category creation.
var deferral = args.GetDeferral();
// Get creation status and if failed, let's
// keep the dialog opened.
var success = await ViewModel.CreateCategory();
args.Cancel = !success;
// Complete deferral to close the dialog.
deferral.Complete();
}
示例4: ContentDialog_PrimaryButtonClick
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
var deferral = args.GetDeferral();
var command = TemperatureEditViewModel.SaveTemperatureSettingCommand;
if (command.CanExecute(null))
{
await command.ExecuteAsync(null);
}
if (TemperatureEditViewModel.HasErrors)
{
args.Cancel = true;
}
deferral.Complete();
}
示例5: GiveGoldDialog_OnPrimaryButtonClick
private async void GiveGoldDialog_OnPrimaryButtonClick(ContentDialog sender,
ContentDialogButtonClickEventArgs args)
{
// Get the deferral because we need to await the
// annotation to post.
var deferral = args.GetDeferral();
// Get creation status and if failed, let's
// keep the dialog opened.
var success = await ViewModel.PostAnnotationToService();
args.Cancel = !success;
// Complete deferral to close the dialog.
deferral.Complete();
}
示例6: ContentDialog_PrimaryButtonClick
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
var deferral = args.GetDeferral();
try
{
if (ViewModel.SaveCommand.CanExecute(null))
await ViewModel.SaveCommand.Execute();
else
args.Cancel = true;
}
finally
{
deferral.Complete();
}
}
示例7: ContentDialog_PrimaryButtonClick
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
var deferral = args.GetDeferral();
args.Cancel = false;
NewEntry = new PasswordEntry
{
Id = -1,
Domain = Domain.Text,
Username = Username.Text,
PasswordLength = SettingsProvider.DefaultPasswordLength,
UseCapitalLetters = SettingsProvider.IncludeCapitalsByDefault,
UseDigits = SettingsProvider.IncludeDigitsByDefault,
UseSpecialCharacters = SettingsProvider.IncludeSpecialsByDefault,
};
PasswordStorage.Entries.Add(NewEntry);
deferral.Complete();
}
示例8: ContentDialog_PrimaryButtonClick
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
// Ensure the user name and password fields aren't empty. If a required field
// is empty, set args.Cancel = true to keep the dialog open.
if (string.IsNullOrEmpty(UserNameTextBox.Text))
{
args.Cancel = true;
ErrorTextBlock.Text = "User name is required.";
return;
}
else if (string.IsNullOrEmpty(PasswordTextBox.Password))
{
args.Cancel = true;
ErrorTextBlock.Text = "Password is required.";
return;
}
// If you're performing async operations in the button click handler,
// get a deferral before you await the operation. Then, complete the
// deferral when the async operation is complete.
var deferral = args.GetDeferral();
var mobileCredentials = new MobileCredentials(UserNameTextBox.Text, PasswordTextBox.Password);
var resultTask = Task.Run(async () => await PorabaViewModel.TryLogin(mobileCredentials));
var result = resultTask.Result;
if (result == LoginResult.Success)
{
this.Result = LoginResult.Success;
Credentials.SaveCredentialToLocker(mobileCredentials);
}
else
{
Result = result;
args.Cancel = true;
}
deferral.Complete();
}
示例9: OnPrimaryClick
private void OnPrimaryClick( object sender, ContentDialogButtonClickEventArgs e )
{
Contract.Requires( e != null );
if ( primary == null )
return;
var parameter = dialog.PrimaryButtonCommandParameter;
deferral = e.GetDeferral();
if ( secondary != null )
secondary.RaiseCanExecuteChanged();
primary.RaiseCanExecuteChanged();
if ( primary.CanExecute( parameter ) )
primary.Execute( parameter );
}