AdvancedApplicationBar. Improving ApplicationBar features in WP7
For many WP7 developers, the implementation of ApplicationBar is unpleasant. There are dirty rumors in the joke that this component was not developed at all in the MC, but by a team that had nothing to do with silverilght, who wrote the component via the requested interface.
Since in several projects I had to work actively with ApplicationBar, I wrote the AdvancedApplicationBar wrapper, which allows you to significantly reduce the amount of code. In fact, the most common problems can be solved only by XAML markup. So, the main complaints about ApplicationBar that can often be heard:
For those who have tasted MVVM goodies, the unpleasant discovery was the lack of support for data binding (DataBinding), and accordingly, the lack of support for ICommand. It is much more pleasant, for example, to set the IsEnabled property from ViewModel, rather than writing the background code. ')
Absence of the Visibility property - sometimes you have to hide some elements depending on certain conditions.
it is inconvenient to work with ApplicationBar together with Panorama and / or Pivot. Quite often it is necessary to display different elements on each tab. ApplicationBar partially helps out in resources that are substituted for the SelectionChanged event, but the code for maintaining the IsEnabled properties, etc., is significantly more complicated.
In addition, if the same button should always be displayed, you have to duplicate it in each implementation.
Unfortunately, the extension cannot be used to solve these problems, since the ApplicationBar cannot be expanded, it can only be inherited, giving some room for improvement . But nevertheless, not as convenient features as when expanding.
Also, despite the fact that ApplicationBar implements the IApplicationBar interface, which is a Page property, it cannot be substituted for an alternative implementation, since only the ApplicationBar implementation is accepted.
when developing the AdvancedApplicationBar, I tried to provide a solution to typical problems with markup in XAML alone, without the need to write background code.
How to connect To use, you need to add a link to sh.dll and add xmlns space to the page: Sh = "clr-namespace: Sh; assembly = Sh"
Since the AdvancedApplicationBar works like a wrapper on the main ApplicationBar, it must be placed inside the main panel (usually the Grid)
Panorama / Pivot support: Since practically in each application it was necessary to implement the ability to specify different buttons in the ApplicationBar for each tab of Panorama and sometimes Pivot, I decided to abandon the need to add AppButtons and MenuItemes only inside the ApplicationBar.
For example, if we need to always have the add buttons in the first place on the page and the settings button at the end and between them we must have elements specific to the specific tabs of the panorama, we can place the add button TO the panorama in each PanoramaItem we can place the AdvancedApplicationBarIconButton and AdvancedApplicationBarMenuItem we need: and at the end we can place the settings button.
A small illustration of the possibility of working with AdvancedApplicationBar without additional code, some XAML tools (and interaction with AppBar via DataBinding):
Download the library and source code with a demonstration here.