The official blog of the Windows Presentation Foundation Team
It has been reported that when using a Ribbon hosted in a RibbonWindow in an application targeting .Net 4.0, the SystemMenu does not show in the correct location. See screenshot below.
Please note that this bug does not exist when targetting .Net 3.5. The workaround to this problem is in the attached sample. The essence of the workaround is to override the execution of ShowSystemMenuCommand.
1st thing I noted. Thanks for the workaround. I'll into it. I wonder how it managed to slip with such an obvious bug.
The .NET 4.0 Window class seems to have a different implementation, the EffectiveXXX properties already accounts for the WindowNonClientFrameThickness. The solution above didn't work for me, the menu was still incorrectly placed, after a bit of debugging I changed the function SystemMenuExecuted in the solution above to this and it seems to work fine:
private void SystemMenuExecuted(object sender, ExecutedRoutedEventArgs args)
RibbonWindow rw = sender as RibbonWindow;
if (rw != null)
Point systemMenuTopLeft = new Point();
Thickness nonClientFrameThickness = SystemParameters2.Current.WindowNonClientFrameThickness;
if (rw.FlowDirection == FlowDirection.RightToLeft)
systemMenuTopLeft.X = rw.EffectiveLeft + rw.ActualWidth;
systemMenuTopLeft.X = rw.EffectiveLeft;
systemMenuTopLeft.Y = rw.EffectiveTop;
args.Handled = true;
@Israel Vieira: Thanks for sharing your solution. I am curious about the steps you used to reproduce this issue (wrongly positioned SystemMenu) with the sample app above. Would you please share this information? Standard action of left clicking the application icon seems to position the SystemMenu correctly when I tried it with the sample app. Thanks in advance.