简体   繁体   中英

Bindable application bar on Windows Phone 8.1 Silverlight

I know that in Windows Phone 8.1 we have a new kind of ApplicationBar that comes from the RT framework but I'm developing a Silverlight app and so I have no access to the new bar.

In Windows Phone 8 I used external libs like the Cimbalino Toolit , and now I'm trying to use the same library on 8.1 with no success, even if the author says that the lib is compatible with 8.1.

Here's my simple code (taken from the samples on the lib's site):

...
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:behaviors="clr-namespace:Cimbalino.Toolkit.Behaviors;assembly=Cimbalino.Toolkit"
...

<i:Interaction.Behaviors>
    <behaviors:ApplicationBarBehavior>
        <behaviors:ApplicationBarIconButton Command="{Binding AddItemCommand, Mode=OneTime}" IconUri="/Images/appbar.add.rest.png" Text="add" IsVisible="{Binding IsSelectionDisabled}" />
        <behaviors:ApplicationBarIconButton Command="{Binding EnableSelectionCommand, Mode=OneTime}" IconUri="/Images/appbar.manage.rest.png" Text="select" IsVisible="{Binding IsSelectionDisabled}" />                
    </behaviors:ApplicationBarBehavior>
</i:Interaction.Behaviors>

This works on 8 but it gives this error on 8.1:

Cannot add instance of type 'Cimbalino.Toolkit.Behaviors.ApplicationBarBehavior' to a collection of type 'System.Windows.Interactivity.BehaviorCollection'

Do you have any idea on how to solve this or if there's some kind of alternative to this toolkit?

Using the code in you XMAL like:

<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
    <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
    <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
    <shell:ApplicationBar.MenuItems>
        <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
        <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
    </shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>

Good Luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM