By Fons Sonnemans, 09-mei-2010

I have written a Silverlight Minesweepe game in October 2008. I just published an improved version on Silver Arcade which support right mouse click. I implemented it using the following RightMouseTrigger. You can set the SetHandled property to true. This stops the MouseRightButtonDown event from bubbling to it's parent.

I really love Behaviors, Actions and Triggers. I hope you like it too.

public class RightMouseTrigger : EventTriggerBase<Control> {

    protected override string GetEventName() {

        return "MouseRightButtonDown";


    #region SetHandled Dependency Property

    /// <summary>

    /// Get or Sets the SetHandled dependency property. 

    /// </summary>

    public bool SetHandled {

        get { return (bool)GetValue(SetHandledProperty); }

        set { SetValue(SetHandledProperty, value); }


    /// <summary>

    /// Identifies the SetHandled dependency property.

    /// This enables animation, styling, binding, etc...

    /// </summary>

    public static readonly DependencyProperty SetHandledProperty =




                                    new PropertyMetadata(true));

    #endregion SetHandled Dependency Property

    protected override void OnEvent(EventArgs eventArgs) {

        var ea = eventArgs as MouseButtonEventArgs;

        if (ea != null && SetHandled) {

            ea.Handled = true;





Leave a Comment

Leave a Comment
4 + 7 =


All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.