2017-12-16 6 views
2

私はXamarinフォームの最新バージョンを使用しています。私はコンテンツページを持っています。コンテンツページには、一部のImageCellを含むItemTemplateを持つListViewを持つコンテンツがあります。 1つのリスト要素に触れると、他のページにナビゲートするTapped_Eventを使用します。このページに戻ると、ImageCellのタップカラーはオレンジ色にとどまります。私はこのオレンジ色にとどまりたいとは思わない。誰も私を助けることができますか?リストビュー項目は、ページに戻った後に選択されたままです。

これは私のXAMLコードです:

<?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方法:

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

答えて

1

は、 "選択解除" SelectedItemPushAsyncあなたの後:

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

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

おかげでそれは仕事です! –

関連する問題