首页 > 解决方案 > 具有多个参数的 xamarin 命令

问题描述

我正在使用 MVVM 对 Xamarin 进行编码,需要一些帮助。

我想将所有条目传递给一个命令,以便我可以将它们放在模型视图中的列表中。但我不知道怎么做?所以我希望所有条目一起成为“条目”类中的参数。

有没有其他方法可以做到这一点?

XAML

<StackLayout >
    <StackLayout BindingContext="EntriesEdit">
        <Entry Keyboard="Default" Text="{Binding entry1}"/>
        <Entry  Keyboard="Default" Text="{Binding entry2}"/>
        <Entry  Keyboard="Default" Text="{Binding entry3}"/>
        <Entry  Keyboard="Url" Text="{Binding entry4}"/>
        <Entry  Keyboard="Default" Text="{Binding entry5}">
    </StackLayout>
    <Button x:Name="Save_Button" Command="{Binding AddEntries}"/>
</StackLayout>

```

AddEntriesCommand = new Command(async vm =>  await AddEntries(vm as Entries));

功能

public async Task AddSpace(Entries Entries)
{
    SpacesViewModel.Entrieslist.Add(Entries);
   await  _pageService.PopAsync();
}

标签: c#xamarinmvvm

解决方案


推荐阅读