Hello,
I have ListView like this
<StackLayout Spacing="0"> <ListView x:Name="lvMenu" SeparatorColor="Green"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout Padding="10"> <Label HorizontalOptions="FillAndExpand" VerticalOptions="Center" Text="{Binding Title}" TextColor="#03a9f4" /> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackLayout>
Also have ItemSelected event handler like this
lvMenu.ItemSelected += GotoPage; private void GotoPage(object sender, SelectedItemChangedEventArgs e) { var item = e.SelectedItem as MasterPageItem; if (item != null) { //Change bg if (item.Title == "Logout") { LogoutUser(); } else { NavigationPage nPage = new NavigationPage((Page)Activator.CreateInstance(item.TargetType)) { Title = item.Title }; this.Detail = nPage; this.IsPresented = false; } } } public class MasterPageItem { public string Title { get; set; } public Type TargetType { get; set; } }
Can anyone suggest how to change the selected item's default background color?