Forum Xamarin.Forms

Pass Value by PopAsync

WarwenczackWarwenczack BRMember ✭✭

There's any way to pass value with an PopAsync ?

Tagged:

Best Answer

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    Accepted Answer

    I think no...

    You can use MessagingCenter to send data from B (send) to A (receive)

    Otherwise you can pass A's ViewModel to B, modify it so it should result modified after PopAsync

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    Accepted Answer

    I think no...

    You can use MessagingCenter to send data from B (send) to A (receive)

    Otherwise you can pass A's ViewModel to B, modify it so it should result modified after PopAsync

  • NMackayNMackay GBInsider, University admin

    Not that I know off, If your looking at an MVVM Framework at some stage then Prism makes this really easy and allows you to pass parameters back to the previous page/viewmodel.

  • WarwenczackWarwenczack BRMember ✭✭

    @NMackay said:
    Not that I know off, If your looking at an MVVM Framework at some stage then Prism makes this really easy and allows you to pass parameters back to the previous page/viewmodel.

    with Bindings ?

  • WarwenczackWarwenczack BRMember ✭✭

    Let me explain better my situation...

    I Have two pages (A) and (B),
    in a (A) page, i click on a searchBox and send to the page (B) with the value to search,
    at my (B) page, load a listView with the searched items,
    i want to select a value in the (B) page and confirm,
    after this at my (A) page the comboBox will be setted with the value...

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Pass A's ViewModel to B

    in A's ViewModel should exist a Property in Binding with the ComboBox

    B should set to "true" the Property

    It should work

  • NMackayNMackay GBInsider, University admin

    @Warwenczack

    Yes, I pass bound objects as parameters via the navigation service to other view models, just look at the parameters dictionary when the VM A is navigated back to and set whatever binding you want.

    You can pass the entire view model I guess but that can get pretty heavy.

  • NMackayNMackay GBInsider, University admin

    I'm not plugging Prism btw, I just know it makes this kind of scenario really easy and clean to implement.

  • WarwenczackWarwenczack BRMember ✭✭
    edited July 2017

    @NMackay said:

    @Warwenczack

    Yes, I pass bound objects as parameters via the navigation service to other view models, just look at the parameters dictionary when the VM A is navigated back to and set whatever binding you want.

    You can pass the entire view model I guess but that can get pretty heavy.

    I'm trying to understand some concepts, there's no much time that I work with Xamarin ...

  • VelocityVelocity NZMember ✭✭✭

    You could also use RX observables aka Reactive UI.
    If you are desperate, you could probably extend NavigationPage and write a custom PopAsync method which accepts arguments to pass back to the next page. But, I wouldn't recommend this.

  • WarwenczackWarwenczack BRMember ✭✭

    @AlessandroCaliaro said:
    I think no...

    You can use MessagingCenter to send data from B (send) to A (receive)

    Otherwise you can pass A's ViewModel to B, modify it so it should result modified after PopAsync

    Thanks!

Sign In or Register to comment.