@@ -219,7 +219,7 @@ private CustomPopupPlacement[] ComboBoxCustomPopupPlacementCallback(
219
219
220
220
var visualAncestry = PlacementTarget . GetVisualAncestry ( ) . ToList ( ) ;
221
221
222
- var parent = visualAncestry . OfType < Panel > ( ) . ElementAt ( 1 ) ;
222
+ var parent = visualAncestry . OfType < Panel > ( ) . First ( ) ;
223
223
VisiblePlacementWidth = TreeHelper . GetVisibleWidth ( ( FrameworkElement ) PlacementTarget , parent , FlowDirection ) ;
224
224
225
225
var data = GetPositioningData ( visualAncestry , popupSize , targetSize ) ;
@@ -246,12 +246,10 @@ PositioningData GetPositioningData(IEnumerable<DependencyObject?> visualAncestry
246
246
{
247
247
var locationFromScreen = PlacementTarget . PointToScreen ( new Point ( 0 , 0 ) ) ;
248
248
249
- var mainVisual = visualAncestry . OfType < Visual > ( ) . LastOrDefault ( ) ;
250
- if ( mainVisual is null ) throw new ArgumentException ( $ "{ nameof ( visualAncestry ) } must contains at least one { nameof ( Visual ) } control inside.") ;
251
-
252
- var controlVisual = visualAncestry . OfType < Visual > ( ) . FirstOrDefault ( ) ;
253
- if ( controlVisual == null ) throw new ArgumentException ( $ "{ nameof ( visualAncestry ) } must contains at least one { nameof ( Visual ) } control inside.") ;
254
-
249
+ var mainVisual = visualAncestry . OfType < Visual > ( ) . LastOrDefault ( )
250
+ ?? throw new ArgumentException ( $ "{ nameof ( visualAncestry ) } must contains at least one { nameof ( Visual ) } control inside.") ;
251
+ var controlVisual = visualAncestry . OfType < Visual > ( ) . FirstOrDefault ( )
252
+ ?? throw new ArgumentException ( $ "{ nameof ( visualAncestry ) } must contains at least one { nameof ( Visual ) } control inside.") ;
255
253
var screen = Screen . FromPoint ( locationFromScreen ) ;
256
254
var screenWidth = ( int ) screen . Bounds . Width ;
257
255
var screenHeight = ( int ) screen . Bounds . Height ;
0 commit comments