title: How do I add a button with action to ShowInputAsync from MahApps.Metro
body: <p>I'm using MahApps Metro in a wpf application.  I'm using their ShowInputAsync() <a href="http://mahapps.com/controls/dialogs.html" rel="nofollow">Dialog</a>. </p>
  
  <p>I'm wanting to save a directory, and I wanted to use a Dialog to set that directory.</p>
  
  <p>So, In my MainWindow.xaml.cs, I have something similar to;</p>
  
  <pre><code>if(string.IsNullOrEmpty(userInputDirectory)) 
  {
      userInputDirectory = await this.ShowInputAsync("Your Directory", "Set Your Directory");
  }
  </code></pre>
  
  <p>That works well, and I like how the Dialog looks, but I'd like to add a Browse button, so that they don't have to have a directory location memorized, and can just browse to the desired directory using a <code>System.Windows.Forms.FolderBrowserDialog();</code></p>
  
  <p>Like I said, I like how it looks now, and I don't want to remove the other two buttons, or replace a button, I'd just like to add one.  Any help is appreciated.</p>
  
  <p><strong>Edit1</strong></p>
  
  <p>I created a new User Control, by right clicking on the project -> Add... -> User Control -> User Control (WPF), and changed it from <code>UserControl</code> to <code>Dialogs:BaseMetroDialog</code>.  I also added the xmlns for Controls.  I'm getting an error <code>Exception: Cannot create an instance of "BaseMetroDialog"</code>.  Code is below.</p>
  
  <pre><code>&lt;Dialogs:BaseMetroDialog x:Class="testApp.CustomDialog"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
           xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
           xmlns:Dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"          
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
           mc:Ignorable="d" 
           d:DesignHeight="300" d:DesignWidth="300"&gt;
      &lt;Grid&gt;
  
      &lt;/Grid&gt;
  &lt;/Dialogs:BaseMetroDialog&gt;
  </code></pre>
  
  <p>My .cs file</p>
  
  <pre><code>namespace testApp
  {
  /// &lt;summary&gt;
  /// Interaction logic for CustomDialog.xaml
  /// &lt;/summary&gt;
      public partial class CustomDialog : CustomDialog
      {
          public CustomDialog()
          {
              InitializeComponent();
          }
      }
  }
  </code></pre>
  
  <p>The error I'm getting in the .xaml file is shown in the xaml window before I try to run the program.</p>
  
  <pre><code>InnerException: Exception has been thrown by the target of an invocation.
      StackTrace
           at System.RuntimeTypeHandle.CreateInstance(RuntimeType type,     Boolean publicOnly, Boolean noCheck, Boolean&amp; canBeCached,     RuntimeMethodHandleInternal&amp; ctor, Boolean&amp; bNeedSecurityCheck)
  at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark)
  at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark)
  at System.Activator.CreateInstance(Type type, Boolean nonPublic)
  
  InnerException: Object reference not set to an instance of an object
      NullReferenceException: Object reference not set to an instance of an object.
          StackTrace
              at MahApps.Metro.Controls.Dialogs.BaseMetroDialog.HandleTheme()
              at MahApps.Metro.Controls.Dialogs.BaseMetroDialog.Initialize()
              at MahApps.Metro.Controls.Dialogs.BaseMetroDialog..ctor()
  </code></pre>
  
  <p><strong>Edit2</strong></p>
  
  <p>In case anybody else finds this, and is having the same problem, the MahApps.Metro team (Which is awesome, and very helpful) didn't add CustomDialog fixes until 1.1.3 APHA, and instead of BaseMetroDialog, you should use CustomDialog. </p>