答案 0 :(得分:1)
可以使用互操作程序进行Win32调用...首先覆盖Window的SourceInitialized方法并添加以下内容:
public const uint MyMenuItemID = 0x0555;
private const uint MF_BYCOMMAND = 0x00000000;
private const uint MF_BYPOSITION = 0x00000400;
[DllImport ("user32.dll")]
private static extern IntPtr GetSystemMenu (IntPtr hWnd, bool bRevert);
[DllImport ("user32.dll")]
private static extern bool InsertMenu (IntPtr hMenu, uint uPosition, uint uFlags, uint uIDNewItem, string lpNewItem);
private void Window_SourceInitialized (object sender, EventArgs e)
{
HwndSource source = PresentationSource.FromVisual (this) as HwndSource;
if (source != null) {
IntPtr hMenu = GetSystemMenu (source.Handle, false);
InsertMenu (hMenu, 5, MF_BYPOSITION, MyMenuItemID, "my own MenuItem");
}
}