miércoles, 26 de enero de 2011

Silverlight Right Mouse Button

In Silverlight 4, there is a new feature very useful for so many scenarios. This is the right mouse button characteristic that you normally use to show a context menu. But there are some things that you have to take into account.
1.- You need to set the Handler mouse event to false to hide the default Silverlight message box. For every event handler (either MouseRightButtonUp or MouseRightButtonDown), you need to set this property to false like the following example:







     
private void ActionInvolvingTheEvent(object sender, MouseButtonEventArgs e)
{
      e.Handled = true;

     //... Actions
}




2.- If you want to use the event in the up action, you need to include in the down action (MouseRightButtonDown) the handler to false.


private void ReleaseMouseRightButton(object sender, MouseButtonEventArgs e)
{
      e.Handled = true;
}

3.- If you want to hide the default Silverlight message box, you have to add the below lines in the MouseRightButtonDown event for the main LayoutRoot control.

private void DeactivateSilverlightMessage(object sender, MouseButtonEventArgs e)
{
      e.Handled = true;
}

Cheers :)

No hay comentarios:

Publicar un comentario