0
I have a listview in my app and created in my Viewmodel a method Carregarlistview();
When I call it by the constructor of my Viewmodel, an Observablecollection list is loaded and Binding is given in my view.
When I call the Load Stview() method by a command from a button the Load Stview() method is called and the list is loaded, but does not give Binding in my view.
Does anyone know why?
This is my listview
<ListView Grid.Row="2"
Grid.Column="1"
Grid.ColumnSpan="3"
ItemsSource="{Binding ListaIntervalos }"
HasUnevenRows="true">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Row="1" Grid.Column="0" Text="{Binding De}" FontSize="20" VerticalOptions="Start" TextColor="Black"/>
<Label Grid.Row="1" Grid.Column="1" Text="{Binding Ate}" FontSize="20" VerticalOptions="Start" TextColor="Black"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
And in my View Model it’s like this
public ObservableCollection<Intervalo> ListaIntervalos { get; private set; } = new ObservableCollection<Intervalo>();
//Construtor
public VMBuscarSalto()
{
// Aqui funciona
this.CarregaIntervalos();
}
public Command BuscaSaltosCommand
{
get
{
return new Command(() => ExecuteBuscaSaltosCommand());
}
}
private void ExecuteBuscaSaltosCommand()
{
// Aqui a lista é carregada mas não dá o bind no listview
this.CarregaIntervalos();
}
Would have How to create a Minimum, Complete and Verifiable example in order to be analysed ?
– NoobSaibot
Hello, thank you for your attention. I complemented my post with code.
– Vagner C. S.