xamarin/Xamarin.Forms

When using DataTemplate, If view is created outside the DataTemplate and returns the view instance, Created View is not loaded in the Datatemplate

Ouverte

#4 642 ouverte le 5 déc. 2018

 (5 commentaires) (0 réaction) (0 personne assignée)C# (1 926 forks)batch import
e/8 :clock8:help wantedinactiveproposal-opent/bug :bug:t/enhancement ➕up-for-grabs

Métriques du dépôt

Stars
 (5 644 étoiles)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

Description

We would like to bring to your notice a bug that we encountered recently, When using DataTemplate if CustomView is created outside and returns the customView instance inside the DataTemplate, Created views are not loaded in the DataTemplate. Follow the snaps to get the differences between View is created outside the DataTemplate and returns created View instance inside the DataTemplate, with Views are created inside the DataTemplate. We suspect issue was rendering native view object, Also we have attached the tree hierarchy which clearly explains while creating view outside the DataTemplate views are not converted as NativeView. For further clarification we have attached the Android renderer snaps.

CustomView is created outside the DataTemplate and returns only instance inside the DataTemplate, You can clearly see Label is not placed in Android.View.ViewGroup image

CustomView is created inside the DataTemplate, Here Label is placed in the Android.View.ViewGroup
image

In the above snaps difference is created view(Label) is not placed in Android.View.ViewGroup, This is our issue.

Steps to Reproduce

  1. Run the attached sample
  2. You can see the difference after View gets loaded , In RowIndex 0 and ColumnIndex 0 MyLabel view (Label View created in inside the DataTemplate) text was loaded with pink color
  3. At the RowIndex 0 and ColumnIndex 1 MyLabel1 view(Label View created outside the DataTeamplate and returns only View instance) was not loaded

or

ViewCell cell = new ViewCell();
cell.View = new Label() { Text = "test" };

cell.View.SetBinding(Label.TextProperty, ".");
ListView view = new ListView(ListViewCachingStrategy.RecycleElementAndDataTemplate)
{
	ItemsSource = new[] { 1, 2, 3 },
	ItemTemplate = new DataTemplate(() =>
	{
		return cell;
	}), 
};


return new ContentPage()
{
	Content = view
};

Expected Behavior

If in case of creating views outside the DataTemplate and returns the view instance, View should get loaded.

Actual Behavior

Views are not loaded while creating view outside the DataTemplate.

Basic Information

-- Version with issue: 2.5.1.527436

  • Last known good version: None
  • IDE:
  • Platform Target Frameworks: Xamarin forms all platforms -Android Support Library Version: Tested in 25.4.0.2
  • Nuget Packages: 2.5.1.527436
  • Affected Devices: All devices

Screenshots

image

Reproduction Link

http://www.syncfusion.com/downloads/support/directtrac/general/ze/DataTemplate_SfDataGrid347140047 This issue was reproduced in our SfListView Control also in the same scenario For your reference we have attached the SfListView sample too http://www.syncfusion.com/downloads/support/directtrac/general/ze/ListViewSample776214805

Note : If Packages are nor restored properly, You can download the Syncfusion.Xaamrin.SfDataGrid , Syncfusion.Xamarin.SfListView packages directly from nuget.org

Guide contributeur