I have a collection view with buttons in every row, when the button is press, the collectionview hides and then, another collectionview should showup with different data. The problem is this: the second collectionview never showup, it looks like the observablecollection didn't update the XAML interface, this is my code XAML
<Border >
<Grid RowDefinitions="Auto,*,Auto" ColumnDefinitions="*">
<ScrollView Grid.Row="1" Orientation="Horizontal" >
<Grid>
<!--datagrid de datos 1 -->
<Grid RowDefinitions="Auto,*" HorizontalOptions="Center" IsVisible="{Binding VerMedidoresConProblemas,Mode=TwoWay}" >
<Grid Grid.Row="0" RowDefinitions="*" ColumnDefinitions="40,60">
<Label Grid.Column="0" Text="Field1" />
</Grid>
<CollectionView ItemsSource="{Binding Data1,Mode=TwoWay}" >
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid RowDefinitions="*" ColumnDefinitions="40,Auto">
<Label Grid.Column="0" Text="{Binding Number}" />
<Button Grid.Column="1"
Command="{Binding BindingContext.SearchData2Command,Source={x:Reference RevisionBD}}"
CommandParameter="{Binding}"/>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
<!--DataGrid de Data 2 -->
<Grid RowDefinitions="Auto,*" IsVisible="{Binding VerData2,Mode=TwoWay}">
<Grid Grid.Row="0" RowDefinitions="*" ColumnDefinitions="40,60">
<Label Grid.Column="0" Text="AnotherField1" />
<Label Grid.Column="1" Text="AnotherField2" />
</Grid>
<CollectionView Grid.Row="1"
ItemsSource="{Binding Data2,Mode=TwoWay}" >
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid RowDefinitions="*" ColumnDefinitions="40,60,100,150,150">
<Label Grid.Column="0" Text="{Binding Field_1}" />
<Label Grid.Column="1" Text="{Binding Field_2}" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
</Grid>
</ScrollView>
</Grid>
</Border>
My simplified viewmodel is this:
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(Data1))]
bool verData1;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(Data2))]
bool verData2;
[ObservableProperty]
ObservableCollection<myclass1> data1;
[ObservableProperty]
ObservableCollection<myclass2> data2;
[RelayCommand]
async void SearchData2(myclass1 objeto)
{
Data2=new ObservableCollection<myclass2>(await Services.GetData2(objeto.Id));
VerData2= true;
}
I'm using MAUI, .Net 7, my VS2002 is the version 17.5.4
I'm sure that the "Data2" collection gets data, the command is working good, the problem is the update of the interface, Any Idea where is the problem?