title: How to display alert from ViewModel
body: <p>I want to display alert from <code>ViewModel</code>.</p>
  <p>problem: The name <code>DisplayAlert</code> does not exist in the current context</p>
  <p>How to do that? Below is my code.</p>
  <pre><code>-- XAML
  &lt;Button x:Name=&quot;BtnLogin&quot; Command=&quot;{Binding LoginCommand}&quot; BackgroundColor=&quot;Green&quot; TextColor=&quot;White&quot; WidthRequest=&quot;150&quot; HeightRequest=&quot;60&quot;  Text=&quot;Login&quot; /&gt;
  
  
  --- ViewModel :
  
  class LoginViewModel : ViewModelBase
      {
         
  
          private string _username;
  
          public string Username
          {
              get { return _username; }
              set
              {
                  _username = value;
                  OnPropertyChanged();
              }     
           }
  
          private string _password;
  
          public string Password
          {
              get { return _password; }
              set
              {
                  _password = value;
                  OnPropertyChanged();
              }
          }
  
          public LoginViewModel()
          {          
  
          }
  
          public Command LoginCommand
          {
              get
              {
                  return new Command(ValidateUser);
              }
  
          }     
  
         async void ValidateUser()
          {
              if (_username.Length &gt; 1 &amp;&amp; _password.Length &gt; 1)
              {
                 //await DisplayAlert(&quot;Login&quot;, &quot;Login Success&quot;, &quot;Ok&quot;);
              //--Update:
  
                  UserDialogs.Instance.Alert(&quot;Login Success&quot;, &quot;Login&quot;, &quot;OK&quot;);
              }
              else
              {
                 // display invalid credential
              }
          }
  </code></pre>
  <p><strong>Update</strong>
  There are
  a) Acr.UserDialogs V6.5.1
  b) Acr.XamForms.UserDialog v5.0.0</p>
  <p>I am using the older version which is (b) since I m using PCL .</p>
  <p>I did import it and change the code to use it as above. But there is err msg:
  using Acr.UserDialogs;</p>
  <p>Err Msg:</p>
  <pre><code>Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown.
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in &lt;3fd174ff54b146228c505f23cf75ce71&gt;:0 
    at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in &lt;bd30a18775d94dc8b6263aecd1ca9077&gt;:0 
    at Java.Interop.JniPeerMembers+JniInstanceMethods.FinishCreateInstance (System.String constructorSignature, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0004f] in &lt;bd30a18775d94dc8b6263aecd1ca9077&gt;:0 
    at Android.App.AlertDialog+Builder..ctor (Android.Content.Context context) [0x0007a] in &lt;d855bac285f44dda8a0d8510b679b1e2&gt;:0 
    at Acr.UserDialogs.Builders.AlertBuilder.Build (Android.App.Activity activity, Acr.UserDialogs.AlertConfig config) [0x0000d] in &lt;addbf2648c204949b40c582bd49b7ddd&gt;:0 
    at Acr.UserDialogs.UserDialogsImpl.Alert (Acr.UserDialogs.AlertConfig config) [0x00038] in &lt;addbf2648c204949b40c582bd49b7ddd&gt;:0 
    at Acr.UserDialogs.AbstractUserDialogs.Alert (System.String message, System.String title, System.String okText) [0x00024] in &lt;ec0104dbfc974343b668f7b28f49a1ab&gt;:0 
    at BookingNow.ViewModel.LoginViewModel.ValidateUser () [0x00026] in C:\Users\Edward\documents\visual studio 2017\Projects\BookingNow\BookingNow\BookingNow\ViewModel\LoginViewModel.cs:88 
    --- End of managed Java.Lang.NullPointerException stack trace ---
  java.lang.NullPointerException
      at android.app.AlertDialog.resolveDialogTheme(AlertDialog.java:143)
      at android.app.AlertDialog$Builder.&lt;init&gt;(AlertDialog.java:360)
      at md5270abb39e60627f0f200893b490a1ade.ButtonRenderer_ButtonClickListener.n_onClick(Native Method)
      at md5270abb39e60627f0f200893b490a1ade.ButtonRenderer_ButtonClickListener.onClick(ButtonRenderer_ButtonClickListener.java:30)
      at android.view.View.performClick(View.java:4476)
      at android.view.View$PerformClick.run(View.java:18787)
      at android.os.Handler.handleCallback(Handler.java:730)
      at android.os.Handler.dispatchMessage(Handler.java:92)
      at android.os.Looper.loop(Looper.java:176)
      at android.app.ActivityThread.main(ActivityThread.java:5493)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:525)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
      at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  <p>Thanks</p>