Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
**[View document in Syncfusion Xamarin Knowledge base](https://www.syncfusion.com/kb/12330/how-to-refresh-listview-after-dropping-a-table-in-xamarin-forms-sflistview)**

## Sample

```xaml
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Text="Load Data" Command="{Binding LoadDataCommand}" BackgroundColor="#ddf3f5"/>
<syncfusion:SfListView x:Name="listView" ItemSize="60" FooterSize="50" ItemSpacing="5" ItemsSource="{Binding ContactsInfo}" IsStickyFooter="True" Grid.Row="1">
<syncfusion:SfListView.ItemTemplate >
<DataTemplate>
<code>
. . .
. . .
<code>
</DataTemplate>
</syncfusion:SfListView.ItemTemplate>

<syncfusion:SfListView.FooterTemplate>
<DataTemplate>
<Grid BackgroundColor="Transparent">
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Path=BindingContext.DropTableCommand, Source={x:Reference listView}}"/>
</Grid.GestureRecognizers>
<Label Text="Drop table" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="Subtitle"/>
</Grid>
</DataTemplate>
</syncfusion:SfListView.FooterTemplate>
</syncfusion:SfListView>
<sfbusyindicator:SfBusyIndicator Grid.Row="1" AnimationType="Cupertino" TextColor="#1a508b" IsBusy="{Binding IsLoading}" />
</Grid>

ViewModel.cs:

public Command LoadDataCommand { get; set; }
public Command DropTableCommand { get; set; }

LoadDataCommand = new Command(OnLoadData);
DropTableCommand = new Command(OnDropTable);

private async void OnLoadData()
{
Random r = new Random();
IsLoading = true;
await Database.CreateTableAsync();
for (int i = 0; i < 30; i++)
{
var contact = new Contacts();
contact.ContactName = CustomerNames[r.Next(0, CustomerNames.Count())];
contact.ContactNumber = r.Next(720, 799).ToString() + " - " + r.Next(3010, 3999).ToString();
await Database.AddContactAsync(contact);
}

var items = await Database.GetContactsAsync();
ContactsInfo = new ObservableCollection<Contacts>(items);
IsLoading = false;
}

private async void OnDropTable(object obj)
{
await Database.DropTableAsync();
ContactsInfo.Clear();
}
```