c# - 具有多个参数的 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();
}
解决方案
推荐阅读
- javascript - 编写具有 Web 程序集依赖的 Typescript 库?
- java - Hibernate ORM 是否兼容 GraalVM 原生镜像编译?
- javascript - 在 TypeScript 中强制执行对象键
- powershell - 通过 Powershell Scripting 报告 Jira 工作日志
- java - Mapstruct:将对象内部的列表映射到对象列表
- sql-server - 如何检查 SQL Server 登录是否具有角色“SysAdmin”
- jquery - 选择更改时删除部分 URL 的下拉菜单 | Shopify
- ajax - 如何在开始下一个链式函数之前完成多个 ajax 调用?
- python-3.x - FileNotFoundError 的替代方法是什么:[WinError 3]
- dart - Flutter 必须初始化 const 变量 'IconData'