Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Get Navigation.PushAsync binding context in code behind on target

$
0
0

Hi There,
I am new to Xamarin.Forms and I my experience comes from asp.net web applications. I am starting with a simple app. I have a listview of body parts that gets populated from json from an API. This works. What I want to do now is take the id of the item that is tapped and send that to another page, and in that page take that value and put it on the end another api so I can get a list of exercises for that body part. My problem is that I cannot get that binding context in a variable in code behind of the target page. I have seen plenty of examples on how to set the property of controls using this binding but I haven't seen any that will assign it to a variable. I haven't tried to call the second api yet, just trying to see if I can pass the value to the next page
Here is the navigation code:
var item = ((bodyPrt)e.Item);
var bpid = item.bodyPrtId;
var xercisePage = new exercises();
xercisePage.BindingContext = bpid;
await Navigation.PushAsync(xercisePage);
I have verified that the proper id is captured.
In the exercise page code behind, I created a function to just catch the binding context and show it in the debug window. This is what I have so far:
void getBPID()
{
var bpid = ((bodyPrt)BindingContext).bodyPrtId;
Debug.WriteLine("ID is " + bpid);
}
This is giving me a null exception, so I feel like I am not accessing the correct property.
I should mention that I am not using the MVVM framework. ``
Any help is appreciated,
Rob


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>