2
I have a ListView
with a function so that every 30 seconds ListView
be updated.
When it is triggered click on an item of mine ListView
another screen at that time is called and unfortunately the screen of ListView
It’s still being updated every 30 seconds, so I’d like this update every 30 seconds to stop. I could solve this with an if , but for that I need to know when the ItemTapped
has been triggered, which I don’t know how to implement.
My Listview:
<!-- Listagem de Produtos -->
<ListView x:Name="lstLeilao"
ItemTapped="OnTapLance">
<ListView.ItemTemplate>
<!-- DataTemplate = exibe dados de uma coleção de objetos em um ListView -->
<DataTemplate>
<ViewCell>
...
<!-- Grid de exibição -->
...
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
The function that counts 30 seconds:
//A cada 30 segundos atualiza a tela Leilão Aberto
public void TempoAtualiza()
{
Device.StartTimer ( TimeSpan.FromSeconds(30), () =>
{
if (OnTapLance == true) //AQUI QUE EU IMPLEMENTARIA A FUNÇÃO
return false;
AtualizaDados(usuario);
return true;
});
}
The click function:
//Toque
public void OnTapLance(object sender, ItemTappedEventArgs e)
{
isLoading = true;
var item = (sender as ListView).SelectedItem as LeilaoObjeto;
Navigation.PushAsync(new Lance(Convert.ToInt32(item.ID_LEILAO)));
isLoading = false;
}
Friend your question is very confused. Attention to your if you only have one
=
, if you want to compare values you have to putif (ItemTapped == true)
. But since you are comparing to true (true) you can also putif (ItemTapped)
– lazyFox
In fact if is just an example, it is not a functional code. Itemtapped is an event that is triggered when touching the item in Listview, I need to know whether or not someone touched an item in Listview, what my question means.
– Deivid Souza
To facilitate then @Iazyfox I took the example and put the real application.
– Deivid Souza