Windows Phone 8.1 Silverlight上的可绑定应用程序栏

时间:2014-08-02 14:50:12

标签: c# silverlight xaml windows-phone-8.1 cimbalino

我知道在 Windows Phone 8.1 中我们有一种新的ApplicationBar来自 RT 框架,但我正在开发< em> Silverlight 应用程序,因此我无法访问新栏。

Windows Phone 8 中我使用了外部库,如 Cimbalino Toolit ,现在我试图在8.1上使用相同的库但没有成功,甚至如果作者说lib与8.1兼容。

这是我的简单代码(取自lib网站上的示例):

...
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>

这适用于8,但它在8.1:

上出现此错误
  

无法添加类型的实例&#39; Cimbalino.Toolkit.Behaviors.ApplicationBarBehavior&#39;到一个类型为'System.Windows.Interactivity.BehaviorCollection&#39;

的集合

您是否知道如何解决这个问题,或者是否有某种替代方案可用于此工具包?

1 个答案:

答案 0 :(得分:0)

使用XMAL中的代码,如:

<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>

祝你好运!