c# - How to remove a AppBarButton from a CommandBar -
i have commandbar set xaml:
<page.bottomappbar> <commandbar x:name="maincommandbar" verticalalignment="top" margin="0"> <!--toolbar--> <appbarbutton x:name="appbarbuttonscan" label="scan" click="appbarbutton_click" icon="scan" /> <appbarbutton x:name="appbarbuttonstop" label="stop" click="appbarbutton_click" isenabled="false" visibility="collapsed" icon="stop" /> <appbarbutton x:name="appbarbuttonpair" label="pair" click="pairbutton_click" isenabled="false" icon="link" /> </commandbar> </page.bottomappbar>
i remove button code. tried doing:
maincommandbar.primarycommands.remove( appbarbuttonscan ); maincommandbar.invalidatearrange();
and
maincommandbar.primarycommands.remove( appbarbuttonscan ); maincommandbar.invalidatemeasure();
and
maincommandbar.primarycommands.remove( appbarbuttonscan ); maincommandbar.invalidatearrange(); maincommandbar.invalidatemeasure();
and
maincommandbar.primarycommands.remove( appbarbuttonscan ); maincommandbar.updatelayout();
what see button getting collapsed (or removed) commandbar not update layout, i.e. there empty space left removed button was.
any idea how solve that?