zoukankan      html  css  js  c++  java
  • 使用MVVM绑定AppBar事件

    最近在做一个项目,使用到MVVM,在appbar事件绑定时候发现不知道怎么绑定,查阅资料发现时可以绑定的,需要借助到AppBarUtils,可以到这里http://appbarutils.codeplex.com/下载到。

    具体使用方法如下:

    首先在xmal中添加引用

    xmlns:appbar="clr-namespace:AppBarUtils;assembly=AppBarUtils"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

    然后viewmodel重添加Command

    /// <summary>
    /// 刷新Command
    /// </summary>
    public ICommand RefreshCommand
    {
                get;
                set;
     }

    最后在xmal中添加appbar的绑定

    <phone:PhoneApplicationPage.ApplicationBar>
         <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Resource/icons/appbar.refresh.png" Text="refresh"/>
         </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    <i:Interaction.Behaviors>
       <appbar:AppBarItemCommand Id="refresh" Text="刷新" Command="{Binding Path=RefreshCommand}"></appbar:AppBarItemCommand>
    </i:Interaction.Behaviors>
    代码之美
  • 相关阅读:
    微信小程序
    微信小程序
    微信小程序
    微信小程序
    es5
    es5
    es5||es6
    es5
    5 个常用的软件质量指标
    Solr
  • 原文地址:https://www.cnblogs.com/betterchaner/p/2523753.html
Copyright © 2011-2022 走看看