This question is locked. New answers and comments are not allowed.
MouseRightButtonUp only works then binded from xaml. When binding from code behinde it will not fire.
public
partial
class
MainPage : UserControl
{
public
MainPage()
{
InitializeComponent();
image1.MouseRightButtonDown +=
new
MouseButtonEventHandler(image_MouseRightButtonDown);
image1.MouseRightButtonUp +=
new
MouseButtonEventHandler(image_MouseRightButtonUp);
image3.MouseRightButtonDown +=
new
MouseButtonEventHandler(image_MouseRightButtonDown);
image3.MouseRightButtonUp +=
new
MouseButtonEventHandler(image_MouseRightButtonUp);
}
void
image_MouseRightButtonUp(
object
sender, MouseButtonEventArgs e)
{
MessageBox.Show(
"Works"
);
}
void
image_MouseRightButtonDown(
object
sender, MouseButtonEventArgs e)
{
e.Handled =
true
;
}
}
<
UserControl
xmlns:sdk
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
x:Class
=
"SLContextRightClick.MainPage"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
=
"d"
d:DesignWidth
=
"640"
d:DesignHeight
=
"480"
>
<
Grid
x:Name
=
"LayoutRoot"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"150"
/>
<
RowDefinition
Height
=
"172"
/>
<
RowDefinition
Height
=
"158*"
/>
</
Grid.RowDefinitions
>
<!-- Event binded in code behinde will not work with RadContextMenu.ContextMenu :-( -->
<
Image
Height
=
"150"
HorizontalAlignment
=
"Left"
Margin
=
"187,0,0,0"
Name
=
"image1"
Stretch
=
"Fill"
VerticalAlignment
=
"Top"
Width
=
"200"
Source
=
"/SLContextRightClick;component/Images/Chrysanthemum.jpg"
>
<
telerik:RadContextMenu.ContextMenu
>
<
telerik:RadContextMenu
x:Name
=
"contextMenu"
>
<
telerik:RadMenuItem
Header
=
"Set Vista as Background"
/>
<
telerik:RadMenuItem
Header
=
"Set Beach as Background"
/>
<
telerik:RadMenuItem
Header
=
"Set Forest as Background"
/>
</
telerik:RadContextMenu
>
</
telerik:RadContextMenu.ContextMenu
>
</
Image
>
<
Image
Grid.Row
=
"1"
Height
=
"150"
HorizontalAlignment
=
"Left"
Margin
=
"306,0,0,0"
Name
=
"image2"
Stretch
=
"Fill"
VerticalAlignment
=
"Top"
Width
=
"200"
Source
=
"/SLContextRightClick;component/Images/Penguins.jpg"
MouseRightButtonDown
=
"image_MouseRightButtonDown"
MouseRightButtonUp
=
"image_MouseRightButtonUp"
>
<
telerik:RadContextMenu.ContextMenu
>
<
telerik:RadContextMenu
x:Name
=
"contextMenu2"
>
<
telerik:RadMenuItem
Header
=
"Set Vista as Background"
/>
<
telerik:RadMenuItem
Header
=
"Set Beach as Background"
/>
<
telerik:RadMenuItem
Header
=
"Set Forest as Background"
/>
</
telerik:RadContextMenu
>
</
telerik:RadContextMenu.ContextMenu
>
</
Image
>
<
Image
Height
=
"150"
HorizontalAlignment
=
"Left"
Margin
=
"164,10,0,0"
Name
=
"image3"
Stretch
=
"Fill"
VerticalAlignment
=
"Top"
Width
=
"200"
Source
=
"/SLContextRightClick;component/Images/Tulips.jpg"
Grid.Row
=
"2"
>
</
Image
>
</
Grid
>
</
UserControl
>