xaml - Custom CommandBar to PickerFlyout -
by default pickerflyout
has commandbar
has done , cancel buttons. possible disable done button programmatically? if not there way add custom command bar , replace default one?
with of answer given tried write custom picker pickerflyoutbase. i'm not able add content flyout in xaml. giving me error saying custompicker doesnt support direct content
<button> <button.flyout> <local:custompicker> <textblock margin="20" fontsize="30" text="mypickerflyout test" /> </local:custompicker> </button.flyout> </button public class custompicker:pickerflyoutbase { private appbar originalappbar; private commandbar mycommandbar; private page currentpage; public custompicker() { var cancelbutton = new appbarbutton(); cancelbutton.icon = new symbolicon(symbol.cancel); cancelbutton.label = "cancel"; cancelbutton.click += (s, e) => { this.hide(); }; mycommandbar = new commandbar(); mycommandbar.primarycommands.add(cancelbutton); this.closed += mypickerflyout_closed; this.opening += mypickerflyout_opening; this.placement = windows.ui.xaml.controls.primitives.flyoutplacementmode.full; } private void mypickerflyout_opening(object sender, object e) { currentpage = (windows.ui.xaml.window.current.content frame).content page; if (currentpage != null) { originalappbar = currentpage.bottomappbar; currentpage.bottomappbar = mycommandbar; } } private void mypickerflyout_closed(object sender, object e) { if (currentpage != null) { currentpage.bottomappbar = originalappbar; } } }
pickerflyout
class has confirmationbuttonsvisible property, can use property disable both "done" , "cancel" button.
but there no way disable "done" button. have implement custom "pickerflyout". following simple custom "pickerflyout" based on flyout
, can refer implement own.
public class mypickerflyout : flyout { private appbar originalappbar; private commandbar mycommandbar; private page currentpage; public mypickerflyout() { var cancelbutton = new appbarbutton(); cancelbutton.icon = new symbolicon(symbol.cancel); cancelbutton.label = "cancel"; cancelbutton.click += (s, e) => { this.hide(); }; mycommandbar = new commandbar(); mycommandbar.primarycommands.add(cancelbutton); this.closed += mypickerflyout_closed; this.opening += mypickerflyout_opening; this.placement = windows.ui.xaml.controls.primitives.flyoutplacementmode.full; } private void mypickerflyout_opening(object sender, object e) { currentpage = (windows.ui.xaml.window.current.content frame)?.content page; if (currentpage != null) { originalappbar = currentpage.bottomappbar; currentpage.bottomappbar = mycommandbar; } } private void mypickerflyout_closed(object sender, object e) { if (currentpage != null) { currentpage.bottomappbar = originalappbar; } } }
then can use in xaml like:
<button content="show picker"> <button.flyout> <local:mypickerflyout closed="pickerflyout_closed"> <textblock margin="20" fontsize="30" text="mypickerflyout test" /> </local:mypickerflyout> </button.flyout> </button>
Comments
Post a Comment