I have defined a ControlTemplate in the application resources:
<Application ...>
<Application.Resources>
<ResourceDictionary>
<ControlTemplate x:Key="mytemplate">
<!-- template content here -->
<ContentPresenter ... />
</ControlTemplate>
</ResourceDictionary>
<Application.Resources>
</Application>
Inside the template, there is an ImageButton with an associated Behavior:
<ImageButton ...>
<ImageButton.Behaviors>
<H:MyButtonBehavior />
</ImageButton.Behaviors>
</ImageButton>
Then, I have created different pages based on this template:
<ContentView ControlTemplate="{StaticResource mytemplate}" >
_page code here_
</ContentView>
In the MyButtonBehavior class, the OnAttachedTo methos is properly called when the behavior is attached to the control.
Now, the question: how can I detach the behavior from the control?
I should call something like myimagebuttonref.Behaviors.Clear(), but I cannot understand how to get a reference to the control.
Any help is appreciated, thank you!