出于任何原因,下面代码的最后一行抱怨找不到包含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();
}显然,该类具有正确的名称,以及具有两个参数和正确类型的正确构造函数。那么是什么导致了错误呢?
实际上,我正在尝试修改找到这里的代码,使其具有一个身份验证对话框,该对话框要求一个带有密码框的4-6数字引脚。由于我不应该更改MaHapps地铁代码,所以我复制并试图修改代码以满足我的需要。
发布于 2014-05-18 23:52:09
类InputDialog的构造函数的访问修饰符必须是public,而不是internal。
http://msdn.microsoft.com/en-us/library/7c5ka91b.aspx
修饰符internal意味着它只能在同一程序集中的文件中访问。
修饰符public意味着可以引用InputDialog的任何其他类都可以访问它。
https://stackoverflow.com/questions/23727978
复制相似问题