【发布时间】:2015-02-26 10:21:30
【问题描述】:
我有几个 ContentPages,我想通过点击页面中的一个元素从一个内容页面导航到另一个内容页面。我有我的 ViewModel 类:
class JumpVM : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private INavigation _navigation;
public ICommand NewPage
{
get
{
return new Command(async () =>
{
await _navigation.PushAsync(new MySettingsPage());
});
}
}
public JumpVM() { }
public JumpVM(INavigation navitation)
{
_navigation = navitation;
}
}
这是我的一页(为了篇幅,我只放了相关代码):
BindingContext = new JumpVM(this.Navigation);
....
Image fbInvite = new Image
{
Source = ImageSource.FromResource(Constants.ASSETLOCATION + ".facebookInviteIcon.png"),
HorizontalOptions = LayoutOptions.Center
};
fbInvite.GestureRecognizers.Add(new TapGestureRecognizer(sender =>
{
//navigation in the method below
FaceboonInviteFriends();
fbInvite.Opacity = 0.8;
fbInvite.FadeTo(1);
}));
我希望在单击图像时执行 JumpVM 类中的命令并导航到那里的页面。我该怎么做?
【问题讨论】:
标签: c# mvvm xamarin xamarin.forms