How to show alert popup ?

VaibhavMVaibhavM USMember ✭✭

Hi all,
I was working with the older version of xamarin forms, till that everything was working good but as I have upgraded it to XF version 2.0, my alert popup messages giving me error. Does anyone know how to show alert popup message for xamarin forms 2.0 ?

Thank you.


  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Alert popup is DisplayAlert? Which error do you have?

  • VaibhavMVaibhavM USMember ✭✭

    I have to use the alert popup in ViewModel. So I have created the object of IUserDialogs. I am getting this object as null.

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    Then you should ask @AllanRitchie

  • GeraldVersluisGeraldVersluis NLUniversity ✭✭✭✭

    Could you please show us some code?

  • VaibhavMVaibhavM USMember ✭✭
    edited January 2016

    I have created the object of IUserDialogs like,
    readonly IUserDialogs dialogService;
    dialogService = DependencyService.Get<IUserDialogs>();

    and at last I am showing the alert popup as like

    dialogService.Alert(ex.Message, ERR_TITLE);

    but I am getting "dialogService" as null.

  • GeraldVersluisGeraldVersluis NLUniversity ✭✭✭✭
    edited January 2016

    This is in the FAQ at the GitHub

    I'm using Xamarin Forms and getting a nullreferenceexception when using loading

    This happens when you run loading (or almost any dialog) from the constructor of your page or viewmodel. The view hasn't been rendered yet, therefore there is nothing to render to.

    Maybe that's what's wrong?

    Also you can use it directly as UserDialogs.Instance.Alert(ex.Message, ERR_TITLE);

  • AllanRitchie-oldAllanRitchie-old CAInsider ✭✭✭

    @vaibhavmalokar User dialogs doesn't use the dependency service in Xamarin.Forms. Please review the sample code on github:

  • ThomasBurkhartThomasBurkhart DEMember ✭✭✭✭

    Do I understand this right, that Userdialogs is completely independent from XF and that they're native implementations on each platform?
    Can I call them from any place of my App?

  • AllanRitchie-oldAllanRitchie-old CAInsider ✭✭✭
  • ThomasBurkhartThomasBurkhart DEMember ✭✭✭✭

    That's great. Especially if you have to inform the user if something went wrong in a background thread.

  • VaibhavMVaibhavM USMember ✭✭

    Yupp its working very fine.

    Thanx a lot Gerald.

Sign In or Register to comment.