Use of Xaml DataTemplates

I have defined a popup in the code-behind of a ContentPage with a DataTemplate as follows:

 popUpLayout.PopupView.ContentTemplate = (DataTemplate)Resources["PopUpTestTemplate"];

and then in the ResourceDictionary of the ContentPage like this:

 <DataTemplate x:Key="PopUpTestTemplate">
                <ViewCell>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="2*" />
                            <RowDefinition Height="8*" />
                        </Grid.RowDefinitions>

                        <Frame Grid.Row="0" BackgroundColor="MediumPurple">
                            <Image
                                BackgroundColor="Yellow"
                                HorizontalOptions="Center"
                                Source="big-tick2.png" />
                        </Frame>

                        <Frame Grid.Row="1" BackgroundColor="Yellow">
                                <Label
                                    BackgroundColor="Pink"
                                    FontAttributes="None"
                                    FontFamily="Segoe UI"
                                    HorizontalOptions="Center"
                                    HorizontalTextAlignment="Center"
                                    Text="Test!"
                                    TextColor="Black"
                                    VerticalOptions="Center"
                                    VerticalTextAlignment="Center">
                                </Label>
                        </Frame>
                    </Grid>
                </ViewCell>
            </DataTemplate>

On UWP this renders correctly, with the frames, images and labels displayed.
On iOS however, the frames are rendered, but the content - the image and the label are not displayed.

I have tried various combinations of elements, but cannot get the content to show on iOS. Can you please provide an example showing this type of layout defined in a DataTemplate in XAML.

9 Replies

PM Peter Mortley March 29, 2018 05:39 PM UTC

Just to note this is on version 16.1.0.32


SS Suhasini  Suresh Syncfusion Team March 30, 2018 10:20 AM UTC

Hi Peter, 
 
Thanks for contacting Syncfusion Support. 
 
We checked your query and we are able to reproduce the issue “On iOS the content is not displayed”. We have a logged a bug report for the same and the reported issue will be fixed in the upcoming release. As of now, you can overcome the issue in the sample level, by removing the HorizontalOptions and VerticalOptions set to the content in the DataTemplate.  
 
We have prepared a sample to achieve your requirement, you can download the same from the below link: 
 
Regards, 
Suhasini 



PM Peter Mortley April 26, 2018 03:03 PM UTC

I have retested this with version 16.1.0.37, and the problem still exists on iOS.


SS Suhasini  Suresh Syncfusion Team April 27, 2018 04:52 AM UTC

Hi Peter, 
 
Sorry for the inconvenience caused. The fix for the reported issue is not included in the release with version 16.1.0.37. The fix will be included in 2018 Volume 2 main release which will be rolled out by the last week of May 2018.  
 
Let me know whether you require the custom assemblies for the reported issue. 
 
Regards, 
Suhasini  



PM Peter Mortley July 13, 2018 10:35 AM UTC

Having updated the SfPopup component from 16.1.037 to 16.2.0.42, I am now getting a crash. This is both on UWP and iOS.

I am setting a popup in the code-behind of a ContentPage with a DataTemplate as follows:

popUp.PopupView.ContentTemplate = (DataTemplate)Resources["VRErrorTemplate"];

In the ResourceDictionary of the ContentPage I have defined the template

<DataTemplate x:Key="VRErrorTemplate">
                
This works in 16.1.037

FYI I also have some other shared templates within a MergedDictionary on this ContentPage.

<ResourceDictionary.MergedDictionaries>
                <local:SequenceUpPopUp />
</ResourceDictionary.MergedDictionaries>

These popups can still be displayed  correctly.

After upgrading to 16.2.0.42, I get the error below when attempting to set the ContentTemplate


System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Syncfusion.SfPopupLayout.XForms.UWP
  StackTrace:
   at Syncfusion.XForms.UWP.PopupLayout.PopupLayoutDependencyService.MapPopupViewProperties(String propertyName)
   at Syncfusion.XForms.PopupLayout.PopupView.OnContentTemplatePropertyChanged(BindableObject bindable, Object oldValue, Object newValue)
   at Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent)
   at Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
   at Xamarin.Forms.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess)
   at Syncfusion.XForms.PopupLayout.PopupView.set_ContentTemplate(DataTemplate value)
   at SBSV5X.Views.NamingView.ShowVRError() in C:\Data\Development\SBSV5\SBSV5XRepo\SBSV5X-Syncfusion\SBSV5X\SBSV5X\Views\NamingView.xaml.cs:line 281
   at SBSV5X.Views.NamingView.<OnAppearing>b__12_4(NamingViewModel NamingViewModel) in C:\Data\Development\SBSV5\SBSV5XRepo\SBSV5X-Syncfusion\SBSV5X\SBSV5X\Views\NamingView.xaml.cs:line 113



PM Peter Mortley July 13, 2018 05:08 PM UTC

I have replicated this for you.
Taking the 'Getting Started' sample that you sent me previously as a starting point, I have:
1) Upgraded to Xamarin forms 2.5.1.527436 (To support merged dictionaries)
2) Used SfPopupLayout 16.2.0.42
3) Added a simple merged dictionary.

If you run the included solution and press the 'relativePopup' button, the popup will work from the merged dictionary.
If you press the "Show Popup" button you will see the error described above.

If you downgrade to SfPopupLayout 16.1.0.37, then both buttons will work!

Attachment: GettingStarted_677b8e33.zip


SR Sivakumar R Syncfusion Team July 16, 2018 05:17 PM UTC

Hi Peter,

           

Thanks for your update.

 

We are able to reproduce the reported issue ” Exception occurs when switching ContentTemplate via Merged Dictionaries (Xamarin.Forms.2.5.1.527436) when Displaying pop-up when the SfPopupLayout is not set as root view” and we have logged the bug report for the same. The fix for the reported issue will be included in 2018 Volume 2 service pack 1 release which is expected to available by end of July, 2018.

 

In meantime, You can overcome the issue in sample level by Displaying pop-up when the SfPopupLayout is set as root view. We have modified the sample by displaying popup when SfPopupLayout is set as the root view to fix the issue, you can download the same from the below link.

 

Please find the modified code changes in the below code snippet for fixing the issue in sample level.

public MainPage()

{

    InitializeComponent();

    . . . .

    . . . .

   // Change made for Displaying popup when the SfPopupLayout is set as root view

    popupLayout.Content = stackLayout;

    this.Content = popupLayout;

}

 

Sample Link: http://www.syncfusion.com/downloads/support/forum/136759/ze/UpdateSample-2039889506

 

Regards,

Siva


PM Peter Mortley July 17, 2018 07:05 AM UTC

Thank-you for your response. The SfPopup is proving to be a great control for my UI, and I have implemented multiple use-cases. I have tested the sample that you have attached. 

I have complex screens with the layout designed in XAML, with no code-behind layout. There would be significant work to try and implement the work-around.

Can you please let me have pre-release code as soon as it is available to test please?


SS Suhasini  Suresh Syncfusion Team July 18, 2018 01:48 PM UTC

Hi Peter, 
 
We have created an incident for you under your account for this query, so please follow up with this query in the incident created for you. 
 
Regards, 
Suhasini  


Loader.
Up arrow icon