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

[Enhancement] Xamarin.Forms.TemplateUtilities.GetTemplateChild(string name) should be accessible from exterior namespaces #6747

Closed
Juansero29 opened this issue Jul 2, 2019 · 0 comments
Labels
in-progress This issue has an associated pull request that may resolve it! proposal-open t/enhancement ➕

Comments

@Juansero29
Copy link

Juansero29 commented Jul 2, 2019

Summary

This method should be accessible from other namespaces than only the 'Xamarin.Forms' namespace. It was mentioned by @davidbritch on the 4.1 pre-release blog article as available, but it isn't. When trying to use it from a TemplatedView, I get the error 'TemplateUtilities' is inaccessible due to its protection level. Simply put, Xamarin.Forms.TemplateUtilities should be public, since it has public methods inside.

API Changes

Xamarin.Forms.TemplateUtilities and its public methods would now be accessible outside the Xamarin.Forms namespace.

e.g.

<controls:MyCustomControl... >
    <controls:MyCustomControl.ControlTemplate>
         <ControlTemplate>
              <Label x:Name="myLabel"/>
         </ControlTemplate>
    <controls:MyCustomControl.ControlTemplate>
</controls:MyCustomControl>
namespace MyCustomApp 
{
class MyCustomControl : TemplatedView
{
      Label _myLabel;

       protected override OnApplyTemplate()
       {  
               _myLabel = Xamarin.Forms.TemplateUtilities.GetTemplateChild("myLabel");
       }
}
}

Intended Use Case

I intend to force some properties of a control (let's say a checkbox) under certain conditions inside the code of my CustomControl. This can only be achieved by having a reference to the said checkbox and changing its properties. I already use a 'self-made' GetTemplateChild method, but I would like to use the official API from Xamarin.Forms.

@andreinitescu see this.

@Juansero29 Juansero29 changed the title [Enhancement] Have Xamarin.Forms.TemplateUtilities.GetTemplateChild(string name) be public [Enhancement] Xamarin.Forms.TemplateUtilities.GetTemplateChild(string name) should be accessible from exterior namespaces Jul 2, 2019
andreinitescu added a commit to andreinitescu/Xamarin.Forms that referenced this issue Jul 2, 2019
andreinitescu added a commit to andreinitescu/Xamarin.Forms that referenced this issue Jul 2, 2019
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Jun 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in-progress This issue has an associated pull request that may resolve it! proposal-open t/enhancement ➕
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants