public MenuListView() { List <MenuItem> data = new MenuListData(); ItemsSource = data; VerticalOptions = LayoutOptions.FillAndExpand; BackgroundColor = Color.Transparent; SeparatorVisibility = SeparatorVisibility.None; var cell = new DataTemplate(typeof(MenuCell)); cell.SetBinding(MenuCell.TextProperty, "Title"); cell.SetBinding(MenuCell.ImageSourceProperty, "IconSource"); ItemTemplate = cell; }
public MenuListView() { //gets list data from MenuListData.cs List <MenuItem> data = new MenuListData(); ItemsSource = data; VerticalOptions = LayoutOptions.FillAndExpand; BackgroundColor = Color.Transparent; var cell = new DataTemplate(typeof(ImageCell)); cell.SetBinding(TextCell.TextProperty, "Title"); cell.SetBinding(ImageCell.ImageSourceProperty, "IconSource"); ItemTemplate = cell; //which one is selected, for example the first one SelectedItem = data [0]; }