Question Button Control Template - Context Menu click events

dj1975

New member
Joined
Sep 2, 2015
Messages
3
Programming Experience
10+
Hello all,

I'm a bit stuck, I have a control template for a button, and it has a right click context menu on it. If I want to respond to those, I add a click event to it, which is fine. However, once I add a button to my Windows Application, how do I then respond to the right click event?

Here is my template:

C#:
<Style TargetType="Button">        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="NButton1">
                        <Border.Background>
                            <ImageBrush ImageSource="RootNode.jpg"/>
                        </Border.Background>
                        <Border.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="AddResponse" Click="AddResponse_Click"/>
                                <MenuItem Header="AddCondition"/>
                                <MenuItem Header="AddIF"/>
                            </ContextMenu>
                        </Border.ContextMenu>
                        


                    </Border>
                    
                    
                </ControlTemplate>
                
            </Setter.Value>
            
        </Setter>
    </Style>

The event I want to respond to is AddResponse_Click.

Any idea's?

Many thanks

Darren
 
Top Bottom