Tam*_*eák 5 c# xamarin xamarin.forms
我使用的是最新版本的 Xamarin Forms。我有一个内容页面。内容页面有一个内容,它有一个 ListView,它有一个包含一些 ImageCell 的 ItemTemplate。当我触摸一个列表元素时,我使用 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>
Run Code Online (Sandbox Code Playgroud)
ImageCell_Tapped 方法:
private async void ImageCell_Tapped(object sender, EventArgs e)
{
await Navigation.PushAsync(new MedicationDetailPage((Medication)Medications.SelectedItem));
}
Run Code Online (Sandbox Code Playgroud)
SelectedItem在您的以下内容之后“取消选择” PushAsync:
private async void ImageCell_Tapped(object sender, EventArgs e)
{
await Navigation.PushAsync(new MedicationDetailPage((Medication)Medications.SelectedItem));
// Manually deselect item
Medications.SelectedItem = null;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
510 次 |
| 最近记录: |