I'm trying to implement something similar to OnBackPressed() in a fragment in Xamarin, but the only solutions I found so far are for Java.
Here is one example in Java that does what I want:
OnBackPressedCallback callback = new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
Toast.makeText(mContext, "back pressed", Toast.LENGTH_SHORT).show();
// And when you want to go back based on your condition
if (yourCondition) {
this.setEnabled(false);
requireActivity().onBackPressed();
}
}
};
How could I go about converting that piece of code into C#?