I start the WPF today, I'm trying to implement a custom control.
My problem is that I can not select an element in the template.
My code:
[Generic.xaml]
 <Style x:Key="{x:Type local:ImageButton}" TargetType="{x:Type local:ImageButton}"  BasedOn="{StaticResource {x:Type Button}}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:ImageButton}">
                <StackPanel>
                    // -> My image
                    <Image Source="{Binding Path=Tag, RelativeSource={RelativeSource TemplatedParent}}"></Image>
                </StackPanel>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
[ImageButton.cs]
public class ImageButton : Button
{
    public Image imageOff { get; set; }
    public Image imageOn { get; set; }
    static ImageButton()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageButton), new FrameworkPropertyMetadata(typeof(ImageButton)));
    }
    public ImageButton()
        : base()
    {
        this.MouseEnter += new MouseEventHandler(SetImageON);
    }
    public void SetImageON(object sender, MouseEventArgs e)
    {
       //Here i wanna change my image from StackPanel
    }
}
Am I on the good way ? How can I change that image?