@@ -105,29 +105,33 @@ private CustomPopupPlacement[] ComboBoxCustomPopupPlacementCallback(Size popupSi
105
105
Point offset )
106
106
{
107
107
var locationFromScreen = this . PlacementTarget . PointToScreen ( new Point ( 0 , 0 ) ) ;
108
-
109
- int locationX = ( int ) locationFromScreen . X % ( int ) DpiHelper . TransformToDeviceX ( SystemParameters . PrimaryScreenWidth ) ;
110
- int locationY = ( int ) locationFromScreen . Y % ( int ) DpiHelper . TransformToDeviceY ( SystemParameters . PrimaryScreenHeight ) ;
111
108
112
109
var mainVisual = TreeHelper . FindMainTreeVisual ( this . PlacementTarget ) ;
110
+
111
+ int screenWidth = ( int ) DpiHelper . TransformToDeviceX ( mainVisual , SystemParameters . PrimaryScreenWidth ) ;
112
+ int screenHeight = ( int ) DpiHelper . TransformToDeviceY ( mainVisual , SystemParameters . PrimaryScreenHeight ) ;
113
+
114
+ int locationX = ( int ) locationFromScreen . X % screenWidth ;
115
+ int locationY = ( int ) locationFromScreen . Y % screenHeight ;
116
+
113
117
double realOffsetX = ( popupSize . Width - targetSize . Width ) / 2.0 ;
114
118
double offsetX = DpiHelper . TransformToDeviceX ( mainVisual , offset . X ) ;
115
119
double defaultVerticalOffsetIndepent = DpiHelper . TransformToDeviceY ( mainVisual , DefaultVerticalOffset ) ;
116
120
double upVerticalOffsetIndepent = DpiHelper . TransformToDeviceY ( mainVisual , UpVerticalOffset ) ;
117
121
double downVerticalOffsetIndepent = DpiHelper . TransformToDeviceY ( mainVisual , DownVerticalOffset ) ;
118
122
119
- if ( locationX + popupSize . Width - realOffsetX > SystemParameters . PrimaryScreenWidth
123
+ if ( locationX + popupSize . Width - realOffsetX > screenWidth
120
124
|| locationX + realOffsetX < 0 )
121
125
{
122
126
SetChildTemplateIfNeed ( DefaultContentTemplate ) ;
123
127
124
- double newY = locationY + popupSize . Height > SystemParameters . PrimaryScreenHeight
128
+ double newY = locationY + popupSize . Height > screenHeight
125
129
? - ( defaultVerticalOffsetIndepent + popupSize . Height )
126
130
: defaultVerticalOffsetIndepent + targetSize . Height ;
127
131
128
132
return new [ ] { new CustomPopupPlacement ( new Point ( offsetX , newY ) , PopupPrimaryAxis . Horizontal ) } ;
129
133
}
130
- else if ( locationY + popupSize . Height > SystemParameters . PrimaryScreenHeight )
134
+ else if ( locationY + popupSize . Height > screenHeight )
131
135
{
132
136
SetChildTemplateIfNeed ( UpContentTemplate ) ;
133
137
0 commit comments