I have this code in my collectionView:
<RefreshView>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="60" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<CollectionView
ItemsSource="{Binding Comments}"
SelectionMode="Single">
<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Vertical" ItemSpacing="5" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:Comment">
<Frame Style="{StaticResource CardView}" CornerRadius="10">
<Grid RowDefinitions="Auto, Auto, Auto, *" ColumnDefinitions="80, 250" ColumnSpacing="5">
...
</Grid>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
<CollectionView.EmptyView>
<ContentView>
<StackLayout>
<Label
Text="Some text here"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center" />
</StackLayout>
</ContentView>
</CollectionView.EmptyView>
</CollectionView>
<Button
...
</Button>
<Button
...
</Button>
</Grid>
</RefreshView>
Strange behaviour.... When I start the program with an empty collection, of course, I see.... nothing. No label.
While running, I change the text a little bit, it doesn't matter how, I insert a * at the end, for instance: Text="Some text goes here *" and, voila, suddenly my text shows correctly in the middle of my screen - the expected behavior !
I have tried both in the emulator and in the Android local device. The same behavior.
I have also tried to set the caption of that label at run time - no dice.
I have tried with a image instead of a label. Same thing happens.
Once I make a change in the contents of the EmptyView, no matter what the change, the EmptyView will show its contents for the remainder of my session. If I do not do that, it will stay forever blank.
Is there any solution to this ?
Thank you. Alex.