我正试图通过BarData将FavoritesPage.xaml.cs对象的列表发送到FavoritesPage.xaml.cs。我试过了
MessagingCenter.Send<BarData>(_favoriteBarsList, "FaveBars");
它给了我一个错误,告诉我我不能把发送者从一个列表转换成一个对象。然后我试着用
MessagingCenter.Send<List<BarData>>(_favoriteBarsList, "FaveBars");
视觉工作室对着我尖叫,哈哈!我试着在网上搜索如何通过MessagingCenter发送对象列表,但是找不到任何东西。有人能帮忙吗?
发布于 2021-09-22 07:55:09
发送带有指定参数的命名消息。 参数
TSender- The instance that is sending the message. Typically, this is specified with the this keyword used within the sending object.String- The message that will be sent to objects that are listening for the message from instances of type TSender.TArgs- The arguments that will be passed to the listener's callback.示例
MessagingCenter.Send<MainPage,List<BarData>>(
this, // the context you are on
"FaveBars", // the named message
_favoriteBarsList); // the argument其中MainPage是this的类型,List<BarData>是参数类型
https://stackoverflow.com/questions/69279872
复制相似问题