I have a ListView binded to a list of MenuItem
public class MenuItem
{
public string Icon { get; set; }
public string Title { get; set; }
public string Page { get; set; }
}
public ObservableCollection<BeloteMenuItem> _menuItems = new ObservableCollection<BeloteMenuItem>(
new[]
{
new BeloteMenuItem { Icon = "fa-home" },
new BeloteMenuItem { Icon = null }
});
<ListView x:Name="MenuItemsListView"
SeparatorVisibility="None"
HasUnevenRows="true"
ItemsSource="{Binding MenuItems}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="15,10" HorizontalOptions="FillAndExpand">
<iconize:IconImage HeightRequest="20" Icon="{Binding Icon}" IconColor="Black" WidthRequest="20" />
<Label VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center"
Text="{Binding Title}"
FontSize="17"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
In my example I volontary set one of my icon to null and the app immediately crashes, an the Xamarin.Forms error is not very convenient to debug.
I have a
ListViewbinded to a list ofMenuItemIn my example I volontary set one of my
iconto null and the app immediately crashes, an the Xamarin.Forms error is not very convenient to debug.