How to bind a view model property to PopupView.ContentTemplate ?

Hello Syncfusion Team,
how to bind a view model property to PopupView.ContentTemplate?

Example:
SampleBrowser.SfPopupLayout (DetailsView.xaml.cs):
popupLayout.PopupView.ContentTemplate = new DataTemplate(() =>
            {
                StackLayout stack = new StackLayout();
               ....
                Label label = new Label();
                Label firstLabel = new Label();
                label.SetBinding(Label.TextProperty, new Binding("???", 0));
                ...
                stack.Children.Add(firstLabel);
                stack.Children.Add(label);
                return stack;
            });

Regards, 
Dirk


1 Reply

SS Suhasini  Suresh Syncfusion Team April 24, 2018 11:20 PM UTC

Hi Dirk, 
 
Thanks for contacting Syncfusion Support. 
 
You can bind the property in the ViewModel to the ContentTemplate of Popup. We have prepared a sample to achieve your requirement, you can download the same from the below link. 
 
However we had an issue in setting the Binding for the child views in popup, we fixed the issue internally and have referred the custom assemblies which includes the fix for the Binding issue in the sample attached. You can use that custom assemblies for your requirement. The fix for the Binding issue will be included in 2018 Volume 2 main release which will be rolled out by the last week of May 2018. 
  
Please find the code snippet for Binding the property in the ViewModel in the ContentTemplate of Popup. 
popupLayout.BindingContext = new ViewModel(); 
popupLayout.PopupView.ContentTemplate = new DataTemplate(() => 
    { 
        Label label = new Label(); 
        label.SetBinding(Label.TextProperty, new Binding("CustomerName", BindingMode.TwoWay)); 
        return label; 
    }); 
 
 
Regards, 
Suhasini  


Loader.
Up arrow icon