ipad - How to open custom dialog box / popup using Xamarin.Forms? -
i newbie xamarin.forms , stuck situation want open popup box control details [e.g. view employee details] on click of parent page.
how can open custom dialog box / popup using xamarin.forms?
any example code appreciated?
thanks in advance!
the general purpose of trying achieve can accomplished using pushmodalasync , popmodalasync methods of xamarin.forms navigation object.
the chances enough needing - however - isn't truely modal. explain after small code snippet:-
stacklayout objstacklayout = new stacklayout() { }; // button cmdbutton_launchmodalpage = new button(); cmdbutton_launchmodalpage.text = "launch modal window"; objstacklayout.children.add(cmdbutton_launchmodalpage); // cmdbutton_launchmodalpage.clicked += (async (o2, e2) => { contentpage objmodalpage = new contentpage(); objmodalpage.content = await createpagecontent_page2(); // await navigation.pushmodalasync(objmodalpage); // // code executed here before page dismissed above. }); // return objstacklayout; private async task<stacklayout> createpagecontent_page2() { stacklayout objstacklayout = new stacklayout() { }; // button cmdbutton_closemodalpage = new button(); cmdbutton_closemodalpage.text = "close"; objstacklayout.children.add(cmdbutton_closemodalpage); // cmdbutton_closemodalpage.clicked += ((o2, e2) => { this.navigation.popmodalasync(); }); // return objstacklayout; }
the problem above
await navigation.pushmodalasync(objmodalpage);
will return after animation.
although can't interact previous page, displaying new navigationpage close button shown - parent navigation page still executing behind scenes in parallel.
so if had timers or executing these still called unless stopped those.
you use taskcompletionsource approach outlined in following post how can await modal form dismissal using xamarin.forms?.
note - although can await 2nd page displaying , when page dismissed allowing code execution continue on next line - still not truely modal form. again timers or executing still called on parent page.
update 1:-
to have content appear on top of existing content include on current page, make section of content invisible until need it.
if use outer container such grid supports multiple child controls in same cell, able achieve want.
you want use filled box transparency cover entire page also, control visible, see through section, surrounds inner content section.
Comments
Post a Comment