Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Unable to set ControlTemplate for TemplatedView in Xamarin.Forms version 5.0 #12484

Closed
MuneeshKumarG opened this issue Oct 14, 2020 · 10 comments · Fixed by #12658 or #13279
Closed

Unable to set ControlTemplate for TemplatedView in Xamarin.Forms version 5.0 #12484

MuneeshKumarG opened this issue Oct 14, 2020 · 10 comments · Fixed by #12658 or #13279
Assignees
Labels
a/customrenderer blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. i/regression in-progress This issue has an associated pull request that may resolve it! t/bug 🐛
Milestone

Comments

@MuneeshKumarG
Copy link

MuneeshKumarG commented Oct 14, 2020

We are using customized TemplatedView for our customers like ContentView. Until version Xamarin.Forms 4.8.0.1534, it works fine. When we upgrade to 5.0 version, it stopped.

In platform specific Renderer not working after upgrading 5.0. We have set ControlTemplate in our CustomView constructor. If we remove the constructor, it works fine.

If we set ControlTemplate, native renderer OnElementChanged not working.
It works until 4.8.0.1534.

Please check the below code and update me the solution for this.

MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Sample"
                x:Class="Sample.MainPage" >
    <ContentPage.Content>
        <StackLayout Margin="5">
            <Entry/>
            <local:CustomView/>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

MainPage.xaml.cs

public class CustomView : TemplatedView
    {
        public CustomView()
        {
            this.ControlTemplate = new ControlTemplate(typeof(Grid));
        }
    }

Android project -> Renderer.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Sample;
using Sample.Droid;
using Xamarin.Forms.Platform.Android;
using Forms = Xamarin.Forms;

[assembly: Forms.ExportRenderer(typeof(CustomView), typeof(CustomViewRenderer))]
namespace Sample.Droid
{
    public class CustomViewRenderer : ViewRenderer<CustomView, View>
    {

        public CustomViewRenderer(global::Android.Content.Context context) : base(context)
        {
        }

        protected override void OnElementChanged(ElementChangedEventArgs<CustomView> e)
        {
            base.OnElementChanged(e);
        }

    }
}
@samhouts samhouts added this to New in Triage Oct 14, 2020
@rachelkang
Copy link
Contributor

Hi, @MuneeshKumarG - thanks for submitting this issue! Hmm I wasn't able to reproduce the issue you're describing - could you attach a sample project that reproduces the bug and uses OnElementChanged as you wish so that we can take a closer look? Thanks :)

@rachelkang rachelkang added a/customrenderer s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. s/unverified New report that has yet to be verified t/bug 🐛 labels Oct 14, 2020
@rachelkang rachelkang moved this from New to Needs Info in Triage Oct 14, 2020
@MuneeshKumarG
Copy link
Author

Please find the sample below.

XF5Sample.zip

In 5.0 Xamarin.Forms version OnElementChanged not called, please check.

@Redth Redth removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Oct 16, 2020
@Redth Redth moved this from Needs Info to New in Triage Oct 20, 2020
@mrhemalatha
Copy link

any progress on this?

@PureWeen PureWeen added this to To do in vNext+1 (5.0.0) via automation Oct 29, 2020
@PureWeen PureWeen moved this from To do to Blockers in vNext+1 (5.0.0) Oct 29, 2020
@PureWeen PureWeen moved this from New to Ready For Work in Triage Oct 29, 2020
@PureWeen PureWeen removed the s/unverified New report that has yet to be verified label Oct 29, 2020
@jsuarezruiz jsuarezruiz self-assigned this Oct 29, 2020
@jsuarezruiz jsuarezruiz moved this from Blockers to In Progress in vNext+1 (5.0.0) Oct 29, 2020
@Redth Redth moved this from Ready For Work to Needs Estimate in Triage Oct 29, 2020
@PureWeen PureWeen added the blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. label Nov 2, 2020
@PureWeen PureWeen added this to the 5.0.0 milestone Nov 3, 2020
@jeyakasipandi
Copy link

Any update on this?

@jsuarezruiz jsuarezruiz added the in-progress This issue has an associated pull request that may resolve it! label Nov 13, 2020
@tranb3r
Copy link

tranb3r commented Dec 9, 2020

Is it fixed in 5.0.0 Pre Release 5 ?

@rmarinho rmarinho removed this from Needs Estimate in Triage Dec 15, 2020
@bmacombe
Copy link
Contributor

Glad to see this is a blocker, it causes issues with SyncFusions SFTextInputLayout tested last on pre 5

vNext+1 (5.0.0) automation moved this from In Progress to Done Dec 19, 2020
rmarinho added a commit that referenced this issue Dec 19, 2020
…12658) fixes #12484

* Fixed issue resolving a Renderer from a TemplatedView

* Fixed build error

* Added UITests

Co-authored-by: Rui Marinho <me@ruimarinho.net>
@MuneeshKumarG
Copy link
Author

I have checked this problem in Xamarin.Forms version 5.0.0.1829-pre6. But still issue occurring. OnElementChanged have not called. Please check with already attached sample with XF new version.

@MuneeshKumarG
Copy link
Author

Any update on this?

@MaximMikhisor
Copy link

SyncFusions SFTextInputLayout does not work also with Xamarin.Forms version 5.0.0.1829-pre6

@MuneeshKumarG
Copy link
Author

@MaximMikhisor : SfTextInputLayout used TemplatedView. This forum raised for the TemplatedView problem in 5.0. Now the problem resolved in Xamarin.Forms 5.0.0.1874. Now SfTextInputLayout also working fine with this Xamarin.Forms 5.0.0.1874 version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/customrenderer blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. i/regression in-progress This issue has an associated pull request that may resolve it! t/bug 🐛
Projects
No open projects
10 participants