How to programmatically bind the label element inside the data template of sfPopup

<ContentView.Content>

        <sfPopup:SfPopupLayout x:Name="popupLayout">

            <sfPopup:SfPopupLayout.PopupView>

                <sfPopup:PopupView>

                    <sfPopup:PopupView.ContentTemplate>

                        <DataTemplate x:Name="dataTemplate">

                            <StackLayout x:Name="stkDialog" Margin="1" BackgroundColor="Gray" Orientation="Vertical" VerticalOptions="Center" HorizontalOptions="Center" IsVisible="True">

                                <StackLayout x:Name="stkDialogOuter" BackgroundColor="#ebf0f9" Margin="1" Padding="10">

                                    <Label Style="{StaticResource DefaultLabelBoldStyle}" x:Name="lblDialogTitle" Text="{Binding strTitle}"/>

                                    <StackLayout x:Name="stkDialogInner" Margin="10">

                                        <Label x:Name="lblMessage" Style="{StaticResource DefaultLabelStyle}" Text="{Binding strMessage}" />

                                    </StackLayout>

                                </StackLayout>

                            </StackLayout>

                        </DataTemplate>

                    </sfPopup:PopupView.ContentTemplate>

                </sfPopup:PopupView>

            </sfPopup:SfPopupLayout.PopupView>

        </sfPopup:SfPopupLayout>

    </ContentView.Content>



When I try to set strMessage = "Some text here" in the code, the message does not show up in the popup. I have the code as follows:

public void Show(string message, string title)

{


strMessage = message;

strTitle = title;

popupLayout.Show();

}


ANy help would be appreciated.


1 Reply

KK Karthikraja Kalaimani Syncfusion Team July 13, 2021 09:20 AM UTC

Hi Sree,

Thank you for contacting Syncfusion support.

We suspect that you had missed to set the binding context to the SfPopupLayout containing page. So, only the bounded properties are not showing in the PopupView. We have attached the working sample for your reference, Please refer to the link for the same. 

Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Popup_Demo-2066965377.zip

Regards,
Karthik Raja

Loader.
Up arrow icon