Skip to content

Commit 0ed31ce

Browse files
committed
Update ComboBoxHelper.cs
popup alignment work
1 parent 2ee429c commit 0ed31ce

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

source/iNKORE.UI.WPF.Modern/Controls/Helpers/ComboBoxHelper.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using iNKORE.UI.WPF.Converters;
5+
using iNKORE.UI.WPF.Helpers;
56
using iNKORE.UI.WPF.Modern.Common.Converters;
67
using System.Windows;
78
using System.Windows.Controls;
9+
using System.Windows.Controls.Primitives;
810

911
namespace iNKORE.UI.WPF.Modern.Controls.Helpers
1012
{
@@ -120,12 +122,19 @@ private static void UpdateCornerRadius(ComboBox comboBox, bool isDropDownOpen)
120122
itemContainer.TranslatePoint(new Point(0, -itemContainer.ActualHeight + comboBox.Padding.Top), comboBox) is { Y: not 0 } itemTop)
121123
{
122124
popup.VerticalOffset -= itemTop.Y;
125+
126+
if (itemContainer.ActualHeight - comboBox.ActualHeight > 0)
127+
{
128+
popup.VerticalOffset -= comboBox.ActualHeight;
129+
}
123130
}
124131

125-
if (popup.Child is FrameworkElement frmelmnt && frmelmnt.ActualWidth > comboBox.ActualWidth)
132+
/*popup.HorizontalOffset = popup.Child switch
126133
{
127-
popup.HorizontalOffset = (frmelmnt.ActualWidth - comboBox.ActualWidth) / 2;
128-
}
134+
FrameworkElement fe when fe.ActualWidth > comboBox.ActualWidth =>
135+
-(fe.ActualWidth - comboBox.ActualWidth) / 2,
136+
_ => 0
137+
};*/
129138

130139
if (popup.VerticalOffset is 0)
131140
{

0 commit comments

Comments
 (0)