最近在做一个项目,使用到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>

相关文章:

  • 2022-01-06
  • 2021-07-24
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2021-06-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
相关资源
相似解决方案