Xamarin Forms - My ContentPresenter won't show its Content

Viewed 3790

I'm still getting used to Xamarin Forms, so I have the following control called PopupFrame:

PopupFrame.cs

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PopupFrame : ContentView
{
    public static readonly BindableProperty PopupContentProperty =
        BindableProperty.Create(nameof(PopupContent), typeof(View), typeof(PopupFrame));

    public View PopupContent
    {
        get { return (View)GetValue(PopupContentProperty); }
        set { SetValue(PopupContentProperty, value); }
    }

    public PopupFrame()
    {
        InitializeComponent();
    }
}

PopupFrame.xaml

<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="TestApp.Core.Controls.PopupFrame">
    <Frame>
        <StackLayout>
            <Label Text="--- TEST TITLE ---" />

            <ContentPresenter Content="{TemplateBinding PopupContent}" />
        </StackLayout>
    </Frame>
</ContentView>

In my view:

<popCtl:PopupFrame HorizontalOptions="Center"
                   VerticalOptions="Center">
    <popCtl:PopupFrame.PopupContent>
        <ListView x:Name="ListUsers">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>
                            <Label Text="{Binding Name}"
                                   HorizontalOptions="CenterAndExpand"
                                   VerticalOptions="Center" />
                        </ViewCell.View>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        </popCtl:PopupFrame.PopupContent>
</popCtl:PopupFrame>

So what's happening is that When the ContentView control shows, only the Label (with the text -- TEST TITLE -- is displayed, but not the ListView).

I've also tried replacing the ContentPreseter with a ContentView, but same result: my ListView doesn't not show. And I made sure that data does in fact exist in the ItemsSource of the ListView (set in code-behind).

Is my ContentView setup wrong??

1 Answers
Related