project descriptionAppBarUtils provides out-of-box application bar behaviors/trigger/action for Windows Phone SDK 7.1, including AppBarItemCommand, AppBarItemTrigger, AppBarPropertyBinder, and NavigateWithQueryStringAction. They work for both application bar button and menu item.
get the libraryHey, AppBarUtils is now available
on NuGet Gallery. Simply add it to your project through the NuGet extension from within Visual Studio. If you are using Visual Studio Express, you can still download it from here CodePlex and add it to your project manually.
how-to:
- How to use AppBarUtils in Blend? (English, 简体中文)
- How to do command binding for application bar with AppBarUtils in XAML?
- How to do navigation for application bar with AppBarUtils in XAML?
- How to use actions shipped with Blend with AppBarUtils in XAML?
- How to bind text of an app bar item with AppBarUtils in XAML?
sample code:
<i:Interaction.Behaviors>
<AppBarUtils:AppBarPropertyBinder IsVisible="{Binding SelectedPivotItemIndex, Converter={StaticResource IndexToIsVisibleConverter}}"/>
<AppBarUtils:AppBarItemCommand Id="add" Command="{Binding AddCommand}"/>
<AppBarUtils:AppBarItemCommand Type="MenuItem" Id="clear" Command="{Binding ClearCommand}"/>
<AppBarUtils:AppBarItemCommand Id="locked" Text="{Binding LockButtonDisplayText}" IconUri="{Binding LockButtonIconUri}" Command="{Binding LockCommand}"/>
</i:Interaction.Behaviors>
<i:Interaction.Triggers>
<AppBarUtils:AppBarItemTrigger Type="Button" Id="sync" IsEnabled="{Binding HasData}"
Text="{Binding SyncButtonDisplayText}">
<ec:CallMethodAction MethodName="Sync" TargetObject="{Binding}"/>
</AppBarUtils:AppBarItemTrigger>
<AppBarUtils:AppBarItemTrigger Type="MenuItem" Id="statistic">
<AppBarUtils:NavigateWithQueryStringAction TargetPage="/StatisticPage.xaml">
<AppBarUtils:Parameter Field="hitcount" Value="{Binding HitCount}"/>
<AppBarUtils:Parameter Field="timecount" Value="{Binding TimeCount}"/>
</AppBarUtils:NavigateWithQueryStringAction>
</AppBarUtils:AppBarItemTrigger>
</i:Interaction.Triggers>
You can find a fully functional demo in the downloaded source code.
change history:| version | description |
| 1.4 | [Bug fix] This is a fix to a regression bug when fixing the last bug. Specifically the initial value of IsEnabled is ignored in the demo code. |
| 1.3 | [Bug fix] When using AppBarItemCommand together with MVVM Light Toolkit, especially involving view model locator, the initial value of IsEnabled of an app bar item cannot be set to false via binding to a command object. |
| 1.2 | [New features] AppBarItemBehavior and AppBarItemTrigger provide IconUri dependency property for icon uri binding to view model. |
| 1.1 | [New features] AppBarPropertyBinder enables you to bind properties from app bar to your view model. Thanks w0rddriven for contributing the code! |
| 1.0 RTW | [RTW] Friends, I'm here to announce the AppBarUtils for Windows Phone SDK 7.1 RTW! Thanks for using it! |
| 1.0 RC 3 | [Refactoring (breaking changes)] ItemType, ItemText, and DisplayText are refactored to Type, Id, and Text respectively. GoBackAction was added dedicated for go-back. NavigateWithQueryStringAction no longer supports go-back. |
| 1.0 RC 2 | [New features] AppBarItemTrigger and AppBarItemBehavior now come with a DisplayText property that you can use to bind the Text property of app bar button/menu item to your view model. Typically you will get benefit from it when supporting multi-language in your app. |
| 1.0 RC | [New features] With the IsEnabled dependency property of AppBarItemTrigger, you can now bind the IsEnabled property of app bar button/menu item to your view model. |
| 1.0 Beta 7 | [Bug fix (breaking change)] Looks like the Name property of Parameter conflicts with the predefined Name property of XAML. When you try to put two Parameters with the same Name inside the same page, you will encounter this issue. Renamed it to Field. |
| 1.0 Beta 6 | [Bug fix] When using NavigateWithQueryStringAction with query string parameters and an empty TargetPage, the app will no longer crash. |
| 1.0 Beta 5 | [New features] Let me introduce today's big guy, NavigateWithQueryStringAction. As its name implied, you can set up the query string right inside the xaml. Because it's just a trigger action, it can be used together with any attachable target, not just app bar item. What's more, you can bind the parameter values to the properties of your view model! |
| 1.0 Beta 4 | [Refactoring] The same functionality. But the classes have been refactored to only three: AppBarItemCommand, AppBarItemNavigation, and AppBarItemTrigger. |
| 1.0 Beta 3 | [New features] Now with AppBarButtonClickedTrigger and AppBarMenuItemClickTrigger at hand, you can take advantage of existing trigger actions provided by Blend SDK and more! |
| 1.0 Beta 2 | [New features] The value of IsEnabled property is now based on the return value of CanExecute method and CanExecuteChanged event when doing command binding. |
| 1.0 Beta | [New features] AppBarButtonCommand, AppBarButtonNavigation, AppBarMenuItemCommand, and AppBarMenuItemNavigation behaviors added, supporting basic command binding and navigation for application bar button/menu item. |
follow me on twitter: @allenlooplee