Xamarin.forms 集合SwipeView Xamarin表单未传递参数
出于奇怪的原因,我找不到激发参数的方法。我所知道的几乎都试过了。如果我在没有参数的情况下执行此操作,函数将被激发。但是我需要集合视图中的参数。现在,我只想在页面后面使用它。是否有人可以分享一个示例,说明如何使用集合视图x:name:NotificationList中的信息从后面的页面C#启动此功能 我用的是正常的东西,比如Xamarin.forms 集合SwipeView Xamarin表单未传递参数,xamarin.forms,data-binding,uicollectionview,command,Xamarin.forms,Data Binding,Uicollectionview,Command,出于奇怪的原因,我找不到激发参数的方法。我所知道的几乎都试过了。如果我在没有参数的情况下执行此操作,函数将被激发。但是我需要集合视图中的参数。现在,我只想在页面后面使用它。是否有人可以分享一个示例,说明如何使用集合视图x:name:NotificationList中的信息从后面的页面C#启动此功能 我用的是正常的东西,比如 INotifyPropertyChanged and public event PropertyChangedEventHandler PropertyChanged;
INotifyPropertyChanged and
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
xaml
视图模型
public ICommand DeleteCommand
{
get
{
return new Command<NitificationModel>((arg) =>
{
try
{
if (arg != null)
{
ex.DeleteNotification(arg);
}
}
catch (Exception ex)
{
Debug.Write(ex);
}
});
}
}
public ICommand delete命令
{
得到
{
返回新命令((arg)=>
{
尝试
{
如果(arg!=null)
{
例如,删除通知(arg);
}
}
捕获(例外情况除外)
{
Debug.Write(ex);
}
});
}
}
我觉得您的问题可能与绑定的数据类型有关CommandParameter=“{binding.}”
更改此设置,而使用ListData
集合对象的任何属性。相应地更新您的命令。这样做是为了得到一个想法。另外,您可能还想稍微更改一下命令。按照您的方式,它将在每次绑定时创建并返回一个新实例。我想那不是你想要的。而是使用常规getter属性,然后在构造函数public ICommand DeleteCommand{get;}
//ctorDeleteCommand=new Command(arg=>{})中初始化和赋值命令代码>
public ICommand DeleteCommand
{
get
{
return new Command<NitificationModel>((arg) =>
{
try
{
if (arg != null)
{
ex.DeleteNotification(arg);
}
}
catch (Exception ex)
{
Debug.Write(ex);
}
});
}
}