Windows 安全弹出窗口出现在主应用程序窗口后面

Hee*_*ena 5 c# windows wpf windows-security

我在 WPF 应用程序中使用 Windows 10 API“Passport”和“Window Hello”。

bool keyCredentialAvailable = await KeyCredentialManager.IsSupportedAsync();
if (keyCredentialAvailable)
{
      KeyCredentialRetrievalResult keyCreationResult = await KeyCredentialManager.RequestCreateAsync("Hi", KeyCredentialCreationOption.ReplaceExisting);

}
Run Code Online (Sandbox Code Playgroud)

RequestCreateAsync方法打开弹出窗口,要求输入生物识别信息或密码。这在主窗口后面的屏幕截图中可见。

我没有任何关于这个弹出窗口的参考,我可以把它放在前面。另外,我在 MainWindow 的方法上调用此方法Loaded,以便可以确认主窗口已完全加载。

弹出窗口定位问题 立即发出

预期定位 预期的

小智 0

首先,检查您的函数是否是异步的。

private async void SignInPassport()
{
 bool keyCredentialAvailable = await KeyCredentialManager.IsSupportedAsync();
 if (keyCredentialAvailable)
 {
  KeyCredentialRetrievalResult keyCreationResult = await KeyCredentialManager.RequestCreateAsync("Hi",KeyCredentialCreationOption.ReplaceExisting);
  }
}
Run Code Online (Sandbox Code Playgroud)

如果这不能解决您的问题,请尝试此microsoft-passport-login