Reputation: 43
For whatever reason, the last line in the code below complains about not finding a constructor for InputDialog that contains 2 arguments.
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
I checked the code for InputDialog and found this:
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();
}
Clearly the class has the right name, and the correct constructor with 2 arguments and the correct types. So what gives the error?
I essentially is trying to retrofit the code found here to have a authentication dialog that ask for a 4-6 digit pin With a password Box. Since I shouldn't change MaHapps Metro code, I copied and attempting to modify the code to fit my needs.
Upvotes: 1
Views: 346
Reputation: 21574
The access modifier of the constructor for the class InputDialog
must be public
, not internal
:
http://msdn.microsoft.com/en-us/library/7c5ka91b.aspx
Practical uses for the "internal" keyword in C#
The modifier internal
means that it is accessible only within files in the same assembly
The modifier public
means that it can be accessed by any other class that can reference InputDialog
Upvotes: 2