c# - Add different BottomAppBars in App.xaml -


how add different bottomappbar in app.xaml? need dynamically load different bottomappbar in same or different pages, want add them in app.xaml.

for instance, here have 2 bottomappbars in xaml:

pagebottomappbar1

<page.bottomappbar>     <commandbar name="pagebottomappbar1">         <commandbar.primarycommands>             <appbarbutton label="new"                            icon="page"                            command="{binding addcommand, mode=oneway}"/>             <appbarbutton label="search"                            icon="find" />         </commandbar.primarycommands>          <commandbar.secondarycommands>             <appbarbutton name="logout"                            label="logout"                            command="{binding logoutcommand, mode=oneway}" />         </commandbar.secondarycommands>     </commandbar> </page.bottomappbar> 

pagebottomappbar2

<page.bottomappbar>     <commandbar name="pagebottomappbar2">         <commandbar.primarycommands>             <appbarbutton label="sync"                            icon="sync"                            command="{binding synccommand, mode=oneway}"/>             <appbarbutton label="search"                            icon="find" />         </commandbar.primarycommands>          <commandbar.secondarycommands>             <appbarbutton name="about"                            label="about"                            command="{binding aboutcommand, mode=oneway}" />         </commandbar.secondarycommands>     </commandbar> </page.bottomappbar> 

how can add them in app.xaml can used resource?

here app.xaml:

<application x:class="test.app" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:test"> <application.resources>   <vm:viewmodellocator x:key="locator" xmlns:vm="using:test.viewmodel" />  </application.resources> </application> 

just thought, defining class inherited iobservablevector:

public class commandbarcontent : iobservablevector<icommandbarelement> {} 

then in xaml

<cb:commandbarcontent x:key="firstprimarybar">     <appbarbutton label="new"                        icon="page"                        command="{binding addcommand, mode=oneway}"/>     <appbarbutton label="search"                        icon="find" /> </cb:commandbarcontent> 

add selector/converter (i take example http://tech.pro/tutorial/807/wpf-tutorial-how-to-use-a-datatemplateselector )

<cb:mycommandselector x:key="commandselector" case1="{staticresource firstprimarybar}" case2="{staticresource secondprimarybar}" /> 

then bind commandbar:

<commandbar name="pagebottomappbar1" primarycommands="{binding scenarioparameter,converter={staticresource commandselector}}"> 

i haven't tried it, depending on number of possible scenarios, may solution use.

another option bind visibility property of buttons, have done delete button, button has "jumping" behaviour when changing scenario, kind of weird.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -