Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Xamarin表单-从ListView和Observable集合中删除行_C#_Ios_Mobile_Xamarin.forms_Xamarin.ios - Fatal编程技术网

C# Xamarin表单-从ListView和Observable集合中删除行

C# Xamarin表单-从ListView和Observable集合中删除行,c#,ios,mobile,xamarin.forms,xamarin.ios,C#,Ios,Mobile,Xamarin.forms,Xamarin.ios,我有一个简单的问题。如何从ListView中删除绑定到可观察集合的行 以下是我的XAML代码: <ListView x:Name="MyListView" ItemsSource="{Binding products}"> <ListView.ItemTemplate> <DataTemplate>

我有一个简单的问题。如何从ListView中删除绑定到可观察集合的行

以下是我的XAML代码:

<ListView x:Name="MyListView" ItemsSource="{Binding products}">
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <ViewCell>
                                        <ViewCell.ContextActions>
                                            <MenuItem ClassId="{Binding ProductName}" Clicked="DeleteAction" Text="Delete" IsDestructive="true" CommandParameter="{Binding .}" />
                                        </ViewCell.ContextActions>
                                        <StackLayout Orientation="Horizontal" Spacing="10">
                                            <Image Source="{Binding ProductImage}" />
                                            <Label Text="{Binding ProductName}" />
                                            <Label Text="{Binding ProductPrice, StringFormat='{0:C}'}" />

                                        </StackLayout>
                                    </ViewCell>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView>

假设
ShoppingCart.fbproducts
将持有相同的
ObservableCollection
实例,而不重新创建它。你需要做的就是

ShoppingCart.fbproducts.Remove(ItemYouWantToRemove)

谢谢将军!它起作用了!完美的胜利。
ShoppingCart.fbproducts.Remove(ItemYouWantToRemove)