I have a ControlTemplate defined in App.xaml. Now, I need to be able to handle certain UI events. In Visual Studio's XAML editor, if I attach a handler to an event, the handler is created in App.xaml.cs. However, I need to do this in pages that use this control template.
I'm thinking the only way is to iterate through the elements in the control template and find the right element and create handlers in pages. However, I'm not sure how to access the elements from the ControlTemplate object.
Does Xamarin provide a way to peek into the contents of a ControlTemplate?
Although this is a old topic but the actual Xamarin Forms API provides the following and works out of the box:
contentView.GetTemplateChild("nameOfTheControl")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With