I am learning wpf technology. I have created such custom class, which should react on mouse up event (should show popup menu)
public class CustomControl : UIElement
{
protected override void OnMouseUp(MouseButtonEventArgs args)
{
ContextMenu context_menu = new ContextMenu();
// How to show context_menu at specific point?
}
};
I don't know how to show created context menu at speficic position. It don't have specified Show method. UIElement don't have appropriated ContextMenu property
Edit: I am not using XAML (I don't want create dependency between source code and design)
Using WPF you would design a context menu in XAML usually. A brief tutorial of how to do that is this for example.
Basically you write your context menu within the respective control and use Command
s or mouse events like Click
to assign a specific behaviour.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.