|
1 | 1 | # How to show empty message when listview has no items in xamarin forms |
2 | 2 | This example demonstrates to show empty message when listview has no items by using the visibility property. |
3 | 3 |
|
| 4 | +## Sample |
| 5 | + |
| 6 | +```xaml |
| 7 | +<Grid Padding="{OnPlatform iOS='0,40,0,0'}"> |
| 8 | + <Grid.RowDefinitions> |
| 9 | + <RowDefinition Height="50"/> |
| 10 | + <RowDefinition Height="*"/> |
| 11 | + </Grid.RowDefinitions> |
| 12 | + <Button x:Name="ItemSource" Grid.Row="0" |
| 13 | + Text="Change ItemSource" |
| 14 | + HorizontalOptions="CenterAndExpand" |
| 15 | + VerticalOptions="CenterAndExpand" |
| 16 | + Command="{Binding OnItemsSourceChanged}"/> |
| 17 | + <Grid IsVisible="{Binding IsVisible}" Grid.Row="1"> |
| 18 | + <Label x:Name="label" |
| 19 | + Text = "No Items :(" |
| 20 | + FontSize ="Default" |
| 21 | + HorizontalOptions = "FillAndExpand" |
| 22 | + HorizontalTextAlignment = "Center" |
| 23 | + VerticalTextAlignment = "Center" |
| 24 | + VerticalOptions = "FillAndExpand"/> |
| 25 | + </Grid> |
| 26 | + <syncfusion:SfListView x:Name="listView" Grid.Row="1" ItemsSource="{Binding ContactsInfo}" |
| 27 | + IsVisible="{Binding Path=IsVisible, Converter={StaticResource visibilityConverter}}" |
| 28 | + ItemSpacing="2" ItemSize="30"> |
| 29 | + <syncfusion:SfListView.ItemTemplate> |
| 30 | + <DataTemplate> |
| 31 | + <Label Text="{Binding ContactName}"/> |
| 32 | + </DataTemplate> |
| 33 | + </syncfusion:SfListView.ItemTemplate> |
| 34 | + </syncfusion:SfListView> |
| 35 | +</Grid> |
| 36 | +``` |
| 37 | + |
4 | 38 | See [How to show empty message when listview has no items in Xamarin.Forms](https://www.syncfusion.com/kb/9956/how-to-show-empty-message-when-listview-has-no-items-in-xamarin-forms) for more details. |
5 | 39 | ## <a name="requirements-to-run-the-demo"></a>Requirements to run the demo ## |
6 | 40 |
|
|
0 commit comments