Click here to Skip to main content
12,067,916 members (28,243 online)
Click here to Skip to main content
Add your own
alternative version


3 bookmarked

Making the ApplicationBar bindable

, 12 May 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
How to make the ApplicationBar bindable.


One of the small issues with using MVVM (Model-View-ViewModel) in a WP7 application is that both ApplicationBarIconButton and ApplicationBarMenuItem do not derive from DependencyObject. This means that I can not bind to any of its properties, making a “true” MVVM application a little hard! I created two simple wrappers for these that make it possible to “bind” to a method.

    <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
          IconUri="/Images/appbar_button1.png" Text="Button 1" 
          MethodName="ShowMessage" />
        <controls:MethodApplicationBarIconButton IconUri="/Images/appbar_button2.png" 
           Text="Button 2" MethodName="ShowMessage" />
            <controls:MethodApplicationBarMenuItem Text="MenuItem 1" MethodName="ShowMessage" />
            <controls:MethodApplicationBarMenuItem Text="MenuItem 2" MethodName="ShowMessage" />

The only “little” caveat is that you have to set the BindApplicationBar attached property to true:


And that’s it...

Here is the latest source.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

South Africa South Africa
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.160208.1 | Last Updated 12 May 2011
Article Copyright 2011 by rudigrobler
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid