0

This is about 5th time I am changing this code, and every time when it looks right on Windows 7, popup position is way off on Windows 8, and vice versa. I don't know if it is the order of calling or something else.

Button b = (Button)sender;
Popup1.Placement = PlacementMode.Left;
Popup1.PlacementTarget = b;
Popup1.HorizontalOffset = b.RenderSize.Width; //original button shall be covered with popup
Popup1.VerticalOffset = 0;
Popup1.IsOpen = true;

It is always horizontally offset. I also tried Popup1.HorizontalOffset = b.ActualWidth;

Daniel
  • 1,064
  • 2
  • 13
  • 30

2 Answers2

0

There's a tablet setting under windows 8 which influences the Placement of popups, you can set it to get another PlacementMode. It's called Handedness and should ensure that the popups does not appear under the hand of the user. I did not have this problem yet, but there are others who had:

w8 default tablet settings conflicts with WPF layout

windows 8 popup location

WPF Handedness with Popups

especially the last link could solve your problem.

Community
  • 1
  • 1
Herm
  • 2,956
  • 19
  • 32
0

I think this fixed it:

I set Popup placement as custom. After init I added

Popup1.CustomPopupPlacementCallback += popupFix;

and

CustomPopupPlacement[] popupFix(Size popupSize, Size targetSize, Point p)
{
   p.Y = p.Y - 12; //my fake shadow offset
   p.X = p.X - 12; //my fake shadow offset
   return new CustomPopupPlacement[] {
     new CustomPopupPlacement(p, PopupPrimaryAxis.Horizontal)
   };
}

After that custom HorizontalOffset works.

Daniel
  • 1,064
  • 2
  • 13
  • 30