I am developing a program for the WIN UI. You must call ContentDialog and enter the user’s password.
public async Task<bool> enterPasswordAsync(modeCheckPassword checkPassword)
{
var content= new PasswordBox{Height = 32};
ContentDialog dialog = new ContentDialog();
dialog.XamlRoot = frame.XamlRoot;
dialog.Content = content;
dialog.Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style;
dialog.Title = "Введите пароль";
dialog.PrimaryButtonText = "Войти";
dialog.SecondaryButtonText = "Отмена";
dialog.DefaultButton = ContentDialogButton.Close;
ContentDialogResult result = await dialog.ShowAsync();
while (true)
{
if (await dialog.ShowAsync() == ContentDialogResult.Primary)
{
if (checkPassword.Invoke(content.Password))
return true;
}
else
return false;
}
}
In debugging mode, I looked at what point the program was hanging. Freezes when calling ShowAsync.
When calling ContentDialog, my program freezes and does not process anything anymore. However, calling a simple ContentDialog does not cause any problems.
I watched the project on this site. https://xamlbrewer.wordpress.com/2022/03/09/a-dialog-service-for-winui-3/
I looked at the official Microsoft website https://learn.microsoft.com/ru-ru/uwp/api/windows.ui.xaml.controls.contentdialog?view=winrt-26100#derived_controls_with_winui_styles