我有以下XAML代码:
<ListView x:Name="listView"
Grid.Row="1"
HasUnevenRows="True"
ItemsSource="{Binding DataList}"
SelectedItem="{Binding SelectedData}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout HorizontalOptions="FillAndExpand"
Orientation="Horizontal"
Padding="20,5,20,5">
<StackLayout HorizontalOptions="StartAndExpand" Orientation="Vertical">
<Label FontSize="Medium"
HorizontalOptions="StartAndExpand"
Text="{Binding Name}"
VerticalTextAlignment="Start" />
<StackLayout HorizontalOptions="StartAndExpand" Orientation="Horizontal">
<Label FontSize="Small"
HorizontalOptions="StartAndExpand"
Text="{Binding Info1}"
VerticalTextAlignment="Start" />
<Label FontSize="Small"
HorizontalOptions="StartAndExpand"
Text="{Binding Info2}"
VerticalTextAlignment="Start" />
</StackLayout>
</StackLayout>
<Image HorizontalOptions="End"
IsVisible="{Binding IsDone}"
Source="Image1.png" />
</StackLayout>
</ViewCell.View>
<ViewCell.ContextActions>
<MenuItem Command="{Binding DeleteEntryCommand, Source={x:Reference listView}"
CommandParameter="{Binding .}"
IsDestructive="true"
Text="Delete" />
</ViewCell.ContextActions>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
当我点击某个项目时,它会导航到新的页面。
public Data SelectedData
{
get { return selectedData; }
set
{
selectedData= value;
if(value!=null)
navigationService.For<InfoViewModel>().Navigate();
selectedData=null;
}
}
当我向后导航时, 该项目仍处于选中状态 ,因此我无法再次选择它。
如何让它“释放”该项?