5
votes

I am on the most current version of Xamarin Forms. I have a Content Page. The Content Page has a content that has a ListView that has a ItemTemplate that contains some ImageCell. When I touch one list element I use Tapped_Event which navigate to other page. When I go back this page the ImageCell tapped color stay with Orange. I dont want to stayed with this Orange color. Anybody can help me?

This is my XAML code:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="Spirocco.MedicationPage"
         Title="Gyógyszerek">
<ContentPage.Content>
    <ListView x:Name="Medications" ItemsSource="{Binding Medications}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ImageCell ImageSource="{Binding Icon}" Text="{Binding Name}" Detail="{Binding Type}" Tapped="ImageCell_Tapped" />
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</ContentPage.Content>

ImageCell_Tapped method:

private async void ImageCell_Tapped(object sender, EventArgs e)
    {
        await Navigation.PushAsync(new MedicationDetailPage((Medication)Medications.SelectedItem));
    }
1

1 Answers

4
votes

"Deselected" the SelectedItem after your PushAsync:

private async void ImageCell_Tapped(object sender, EventArgs e)
{
    await Navigation.PushAsync(new MedicationDetailPage((Medication)Medications.SelectedItem));

    // Manually deselect item
    Medications.SelectedItem = null;
}