I’m writing a custom control for a program. The control has a ComboBox in its template, among other things. Something as simple as this works to reproduce:
<Style TargetType="{x:Type local:CustomControl1}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomControl1}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ComboBox />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
If I right-click on this control, the PreviewMouseRightButtonUp event is raised, but the MouseRightButtonUp event is not. I presume this is because the ComboBox control sets e.Handled to true in its own PreviewMouseRightButtonUp event, preventing the other event from being raised. I’m making that guess because if I swap a Rectangle for the ComboBox, I get both events, and if in my custom control I set e.Handled to true in the Preview event I only get the preview event.
The program I’m writing the control for expects both events to be raised when a right-click happens, and I doubt I’ll be able to get them to change this. Am I going to have to recreate the ComboBox in a way that doesn’t eat the preview event, or is there another trick?
You can actually receive handled events passing true in the UIElement.Addhandler call. If it is handled you can raise a new event?
You can use snoop to see if and if so which element sets the e.Handled=true;