New to Telerik UI for .NET MAUI? Start a free 30-day trial

.NET MAUI Popup Content

The Telerik UI for .NET MAUI Popup provides options for setting its content and for defining when it will open and close.

Opening and Closing

To show the Popup control, set IsOpen property to True. By default, the Popup stays open until the IsOpen property is set to False or, in case of a non-modal Popup, until the user clicks outside the control.

Setting the Content

To host content inside the Popup, either add it directly as a child element or use the ContentTemplate Popup property.

The example below demonstrates how to create a sample DataTemplate and set it as the ContentTemplate of the Popup.

1. Add the needed DataTemplate to the page Resources:

    <DataTemplate x:Key="PopupTemplate">
        <telerik:RadBorder CornerRadius="8"
            <Grid Padding="10">
                    <RowDefinition Height="30" />
                    <RowDefinition Height="50" />
                    <RowDefinition Height="30" />
                <Label Text="ACCEPT TERMS" />
                <Label Grid.Row="1"
                       Text="By checking this, you agree to the Terms of Service and Privacy Policy." />
                <telerik:RadButton Grid.Row="2"
                                   Text="Agree &amp; Continue"

2. When you define the Popup either in XAML or as code-behind, apply the ContentTemplate property:

<HorizontalStackLayout VerticalOptions="Start">
    <telerik:RadCheckBox x:Name="checkbox"
            <telerik:RadPopup x:Name="popup"
                              ContentTemplate="{StaticResource PopupTemplate}" />
    <Label Text="Agree to the Terms &amp; Conditions"/>

3. Add the events as shown below:

private void ClosePopup(object sender, EventArgs e)
    popup.IsOpen = false;
private void Checkbox_IsCheckedChanged(object sender, IsCheckedChangedEventArgs e)
    if (e.NewValue == true)
        popup.IsOpen = true;

The following image shows the end result.

.NET MAUI Popup Content Template

See Also

In this article