Skip to content

BindableApplicationBar

Rico Suter edited this page Jun 6, 2015 · 3 revisions
  • Package: MyToolkit.Extended
  • Platform: WP7SL, WP8SL

A wrapper around the ApplicationBar control with support for bindings for the properties and commands.

<phone:PhoneApplicationPage ...
    xmlns:Paging="clr-namespace:MyToolkit.Paging;assembly=MyToolkit.Extended">

    ...

    <Paging:BindableApplicationBar.ApplicationBar>
        <Paging:BindableApplicationBar>
            <Paging:BindableApplicationBarIconButton ... Command="{Binding ...}" />
        </Paging:BindableApplicationBar>
    </Paging:BindableApplicationBar.ApplicationBar>
</phone:PhoneApplicationPage>

To have direct bindings to the ViewModel defined in the page resources:

<phone:PhoneApplicationPage 
    ...
    xmlns:Paging="clr-namespace:MyToolkit.Paging;assembly=MyToolkit.Extended">

    <phone:PhoneApplicationPage.Resources>
        <viewModels:ListPageViewModel x:Key="viewModel" />
    </phone:PhoneApplicationPage.Resources>
    
    <Grid x:Name="LayoutRoot" Background="Transparent" 
          DataContext="{StaticResource viewModel}">
        ...
    </Grid>
    
    <Paging:PhonePage.ApplicationBar>
        <Paging:BindableApplicationBar DataContext="{Binding viewModel}">
            <Paging:BindableApplicationBarIconButton 
                Command="{Binding MyCommand}" />
        </Paging:BindableApplicationBar>
    </Paging:PhonePage.ApplicationBar>
</phone:PhoneApplicationPage>
Clone this wiki locally