Custom popup, return data to calling page

LindsayMilesLindsayMiles CAMember ✭✭✭

Hello,

I've looked at various popup or modal page solutions for this.

Custom popup with 3-4 radio btns to choose then enter text, press ok, pass the selection and text back to the calling page, hide/close popup.

Any good samples are welcome, I'd rather no re-invent the wheel.

Thx!

Answers

  • JulienRosenJulienRosen CAMember ✭✭✭✭
    edited May 2017

    use a ViewModel.

    create your popup. give it a binding context of your new view model. close the popup and maintain a reference to the view model. you not have info for everything that was in the popup.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    rg.plugins.popups is a really good popups package that we've been using for many months and I am confident in recommending it.

    On the other hand, things like "radio buttons" are not mobile device controls across all platforms. You probably want to update your UI expectations to us the Switch control.

    As for passing the data back to the caller you can use a couple techniques that aren't really Xamarin specific.
    1 - Treat the popup just like any other dialog: Show it, store the results within it, close it... but the caller still has a reference to it so it can get the data. Just like a SaveFileDialog in windows. Caller opens it, user does their thing and closes it, then the caller checks the FilePath property before disposing it.
    2 - Have the popup reference the same ViewModel as the caller. Then there is nothing to pass since its all the same shared ViewModel.

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    I wrote an answer in this post.

    It's hard to find. There are already 8 pages of threads when I searched for "popup result".

  • LindsayMilesLindsayMiles CAMember ✭✭✭

    @JulienRosen, @ClintStLaurent, thanks guys, will consider all...
    Have considered rg.plugins.popups and will try. As with all the third party components and libraries, one break breaks everything and we're back at square one...

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    @LindsayMiles said:
    @JulienRosen, @ClintStLaurent, thanks guys, will consider all...
    Have considered rg.plugins.popups and will try. As with all the third party components and libraries, one break breaks everything and we're back at square one...

    Yep. Its a trade off. Use the stuff that's already built, been out a while, and gets good feedback, or build everything yourself so you don't have to rely on anyone - and add 3 years to the project. I've been at companies that have "we didn't build it syndrome" and while that "what if" is always present it is nice to actually get a product to market.

  • LindsayMilesLindsayMiles CAMember ✭✭✭

    @MichaelRumpler, thanks, I will try that! Will amend VM to include options for the user and allow choices as well as text.

Sign In or Register to comment.