c# - How get navigation control from a button? -


i know if used view controller can use this:

var scanner = new mobilebarcodescanner(this.navigationcontroller); 

how know navigation using inside of button need use?

public class barreaderbuttonrenderer : buttonrenderer {     protected override void onelementchanged(elementchangedeventargs<button> e)     {         base.onelementchanged(e);          // tried don't worked         var scanner = new mobilebarcodescanner(this.navigationcontroller);          // tried         var scanner = new mobilebarcodescanner(this);          element.clicked += async(s_, e_) => {             // setup our button             // tell our scanner use default overlay             scanner.usecustomoverlay = false;              //we can customize top , bottom text of default overlay             scanner.toptext = "hold camera barcode scan";             scanner.bottomtext = "barcode automatically scan";              //start scanning             var result = await scanner.scan ();              handlescanresult(result);         };     } } 

i can't use code inside button render. or did before?

the project shared application ios , android.

the code creating scanner should stay inside view controller/activity/page. can still use custom button , add code need clicked event handler.

var mycustombutton = new barreaderbutton();  mycustombutton.clicked += async(s, e) => {         var scanner = new mobilebarcodescanner();         scanner.usecustomoverlay = false;          //start scanning         var result = await scanner.scan ();         //do result     }; 

if xamarin.forms have use platform specific code inside page code barcode reader requires context on android:

#if __ios__ var scanner = new mobilebarcodescanner(); #elif __android__ var scanner = new mobilebarcodescanner(forms.context); #endif 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -