A context menu is the menu that appears when you right-click on something. The color-picker's popup isn't a context menu, which is why the
ContextMenuOpening
event doesn't fire. And unless you've explicitly set the
ContextMenu
property, it will return
null
, which is why you're getting a
NullReferenceException
when you try to subscribe to it's
Opened
event.
Looking at
the source code[
^] for the
ColorPicker
control, it doesn't seem to fire an event when the popup opens. Your best bet is probably to subscribe to the property change event for the
IsOpen
property:
DependencyPropertyDescriptor descriptor = DependencyPropertyDescriptor.FromProperty(ColorPicker.IsOpenProperty, typeof(ColorPicker));
descriptor.AddValueChanged(colorpicker, delegate
{
if (colorpicker.IsOpen)
{
}
});