我在Xaml中有如下所示的列表视图
<ListView x:Name="PreviousChatList" ItemsSource="{Binding PreviousMessagesList}" Grid.Row="0" ItemSelected="DeleteMessage">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Vertical">
<Label Text="{Binding }" FontSize="12" TextColor="Black"/>
<StackLayout IsVisible="{Binding ButtonsStackvisibility}" Orientation="Horizontal">
<Button Text="Delete" TextColor="Brown" Clicked="DeleteClicked">></Button>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
这里我想在选择列表中的项目时使ButtonsStackvisibility
为真,
private void DeleteMessage(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
{
_chatWindowViewModel.ButtonsStackvisibility = true;
ApplicationContext.seletedMessageToDelete = e.SelectedItem.ToString();
}
点击DeleteClicked
时
private void DeleteClicked(object sender, EventArgs e)
{
_chatWindowViewModel.MessagesList.Remove(ApplicationContext.seletedMessageToDelete);
},
但我面临的问题是,该项目没有删除,可见性无效。如何解决?