【发布时间】:2014-07-06 20:04:56
【问题描述】:
无论出于何种原因,下面代码中的最后一行抱怨找不到包含 2 个参数的 InputDialog 的构造函数。
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
namespace order
{
public static class DialogManager
{
public static Task<string> ShowInputAsync(this MetroWindow window, string title, string message, MetroDialogSettings settings = null)
{
window.Dispatcher.VerifyAccess();
return HandleOverlayOnShow(settings, window).ContinueWith(z =>
{
return (Task<string>)window.Dispatcher.Invoke(new Func<Task<string>>(() =>
{
if (settings == null)
settings = window.MetroDialogOptions;
//create the dialog control
InputDialog dialog = new InputDialog(window, settings); // error: does not contain a constructor With 2 arguments
我检查了 InputDialog 的代码,发现:
namespace MahApps.Metro.Controls.Dialogs
{
public partial class InputDialog : BaseMetroDialog
{
internal InputDialog(MetroWindow parentWindow)
: this(parentWindow, null)
{
}
internal InputDialog(MetroWindow parentWindow, MetroDialogSettings settings)
: base(parentWindow, settings)
{
InitializeComponent();
}
很明显,该类具有正确的名称,以及带有 2 个参数和正确类型的正确构造函数。那么是什么导致了错误呢?
我实际上是在尝试改进找到here 的代码,使其具有一个要求输入带有密码框的 4-6 位密码的身份验证对话框。由于我不应该更改 MaHapps Metro 代码,因此我复制并尝试修改代码以满足我的需要。
【问题讨论】:
标签: c# wpf mahapps.metro