我有几个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;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的一个页面(为了空间,我只放了相关的代码):
BindingContext = new JumpVM(this.Navigation);
Run Code Online (Sandbox Code Playgroud)
....
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);
})); …Run Code Online (Sandbox Code Playgroud) 当我通过MVVM模式将表单中的按钮按到另一个表单时,我想发送一个值.
这是XAML文件
<Button x:Name="myButton"
Text="RandomButton"
TextColor="#000000"
BackgroundColor="{x:Static local:FrontEndConstants.ButtonBackground}"
Grid.Row="2" Grid.Column="0"
Grid.ColumnSpan="3"
Command="{Binding NewPage}"
CommandParameter="100">
</Button>
Run Code Online (Sandbox Code Playgroud)
这是我ModelView class被重定向到另一种形式的地方.
class JumpMVVM :INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private INavigation _navigation;
public ICommand NewPage
{
get
{
return new Command(async () =>
{
await _navigation.PushAsync(new Page2()); // HERE
});
}
}
public JumpMVVM() { }
public JumpMVVM(INavigation navigation)
{
_navigation = navigation;
}
Run Code Online (Sandbox Code Playgroud)
跳跃工作.如何将"CommandParameter"发送到"Page2"?
谢谢,Dragos
我在google上搜索了如何动态编辑Resources.Values.strings.xml文件,这样我就可以添加我的Facebook Access Token,这样用户在重用应用程序时就不需要再次登录了.是否可以编辑它,或者我是否必须使用其他方法来存储令牌?