I have a page.xaml with a listview. The background color of the page is white and when I tap a ListView item, the background of this item is gray. How can I change this color (of the background selected item) in a cross-platform way?
Page.xaml
page.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace App1.Materie_Universitarie.Diritto_Commerciale
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class indicecommerciale : ContentPage
{
public indicecommerciale()
{
InitializeComponent();
argomentilist.ItemsSource = new List<Argomenti>()
{
new Argomenti()
{
Capitolo = "La società di persone", Descrizione = ""
},
new Argomenti()
{
Capitolo = "Le società di capitali", Descrizione = ""
},
new Argomenti()
{
Capitolo = "I gruppi di società", Descrizione = ""
}
};
}
public class Argomenti: INotifyPropertyChanged
{
public string Capitolo
{
get;
set;
}
public string Descrizione
{
get;
set;
}
public event PropertyChangedEventHandler PropertyChanged;
private Color _backgroundColor;
public Color BackgroundColor
{
get { return _backgroundColor; }
set
{
_backgroundColor = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("BackgroundColor"));
}
}
}
public void SetColors(bool isSelected)
{
if (isSelected)
{
BackgroundColor = Color.FromRgb(0.20, 0.20, 1.0);
}
else
{
BackgroundColor = Color.FromRgb(0.95, 0.95, 0.95);
}
}
}
private void argomentilist_ItemTapped(object sender, ItemTappedEventArgs e)
{
var nme = (Argomenti)e.Item;
switch (nme.Capitolo
)
{
case "Reati contro la persona":
Navigation.PushAsync(new local());
break;
case "Reati contro la bellezza di Bibione":
Navigation.PushAsync(new DirittoPenale1());
break;
}
}
}
}
I Will change with your hints. Thanks a lot for the time that you have lost for me