Arsen Zahray
Arsen Zahray

Reputation: 25287

How to get RibbonApplicationMenuItem's Click event

I'm using Microsoft Ribbon, and I'm trying to get it working.

Here's what I've tried:

<ribbon:RibbonApplicationMenuItem Header="New Project"
    x:Name="MenuNewProject"
    ImageSource="Images/newfolder.ico" 
    Click="MenuNewProject_Click" 
    MouseLeftButtonUp="MenuNewProject_MouseLeftButtonUp" 
    PreviewMouseLeftButtonUp="MenuNewProject_PreviewMouseLeftButtonUp"/>

NONE of the events above (Click,MouseLeftButtonUp,PreviewMouseLeftButtonUp) do fire.

How do I get to know if the user clicked on the RibbonApplicationMenuItem?

Upvotes: 1

Views: 910

Answers (1)

Andrew Jones
Andrew Jones

Reputation: 1001

Can you provide more code as I can't replicate your issue.

Both Click and PreviewMouseLeftButtonUp should fire. (The Preview event is a tunnelling event so handling prevents the corresponding bubble event from firing).

Have you considered using the Command property on the RibbonApplicationMenuItem and hooking that up to a Command on your data context?

Upvotes: 2

Related Questions