I have a list view retrieving data from web api. i have added checkboxes to each row. now i want to delete only the checked rows. How can it be done?
My Xaml file:
<StackLayout VerticalOptions="CenterAndExpand">
<ListView x:Name="postsListView" ItemSelected="postsListView_ItemSelected" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--Data From Web Api-->
<controls:CheckBox x:Name="checkbox2" x:Uid="{Binding Id}" Checked="False" Grid.Row="0" Grid.Column="0"/>
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Name}"/>
<Label Grid.Row="0" Grid.Column="2" Text="{Binding Address}"/>
<Label Grid.Row="0" Grid.Column="3" Text="{Binding Telephone}"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
I am unable to implement the listeners and the delete operations. i need to delete only selected checked rows. MyXaml.cs File:
private String Url = "http://192.168.8.115/NewAPI/api/Employee_Table";
private HttpClient client = new HttpClient();
private ObservableCollection<Employee> _employee;
Employee _Employee = new Employee();
public AddRecordPage ()
{
InitializeComponent ();
}
protected override async void OnAppearing()
{
var response = await client.GetStringAsync(Url);
var Emp = JsonConvert.DeserializeObject<List<Employee>>(response);
_employee = new ObservableCollection<Employee>(Emp);
postsListView.ItemsSource = _employee;
base.OnAppearing();
}
Aucun commentaire:
Enregistrer un commentaire