I have this code:
public partial class PhrasesFrameRenderer : Frame
{
Random rand = new Random();
private int answeredPhraseCount;
private int correctAns;
public PhrasesFrameRenderer()
{
InitializeComponent();
App.PhrasesFrameRenderer = this;
public void abc()
{
....
};
and the custom Renderer
[assembly: ExportRenderer(typeof(PhrasesFrameRenderer), typeof(PhrasesFrameCustomRenderer))]
namespace Japanese.iOS
{
public class PhrasesFrameCustomRenderer : FrameRenderer
{
UISwipeGestureRecognizer leftSwipeGestureRecognizer;
UISwipeGestureRecognizer rightSwipeGestureRecognizer;
PhrasesFrameRenderer frame;
bool rightSwipeEnabled = false;
Can someone explain to me how I can call the ABC function in the Phrases FrameRenderer from the custom Renderer code.
In your CustomRenderer the Element
property is basically the view you declared in the PCL Xamarin Forms class in your case PhrasesFrameRenderer
You just need to cast this property to the class and you will have access to all the public methods and properties.
var frame = (PhrasesFrameRenderer)Element;
frame.abc();
or
var frame = Element as PhrasesFrameRenderer;
if(frame != null)
frame.abc();
This should work.
One note: I would not call the Custom views as Renderer as this can create confusions with its actual renderer. Your custom frame could just be named PhrasesFrame
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With