Skip to content

Commit 77f5923

Browse files
committed
more multi action button
1 parent 0f2396c commit 77f5923

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

MaterialDesignThemes.Wpf/PopupBox.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,21 @@ public enum PopupBoxPlacementMode
2828
/// </summary>
2929
BottomAndAlignRightEdges,
3030
/// <summary>
31+
/// Display the popup below the toggle, and align the center of the popup with the center of the toggle.
32+
/// </summary>
33+
BottomAndAlignCentres,
34+
/// <summary>
3135
/// Display the popup above the toggle, and align the left edges.
3236
/// </summary>
3337
TopAndAlignLeftEdges,
3438
/// <summary>
3539
/// Display the popup above the toggle, and align the right edges.
3640
/// </summary>
37-
TopAndAlignRightEdges
41+
TopAndAlignRightEdges,
42+
/// <summary>
43+
/// Display the popup above the toggle, and align the center of the popup with the center of the toggle.
44+
/// </summary>
45+
TopAndAlignCentres
3846
}
3947

4048
/// <summary>
@@ -211,6 +219,10 @@ private CustomPopupPlacement[] GetPopupPlacement(Size popupSize, Size targetSize
211219
x = 0 - popupSize.Width + targetSize.Width - offset.X;
212220
y = targetSize.Height - Math.Abs(offset.Y);
213221
break;
222+
case PopupBoxPlacementMode.BottomAndAlignCentres:
223+
x = targetSize.Width/2 - popupSize.Width/2;
224+
y = targetSize.Height - Math.Abs(offset.Y);
225+
break;
214226
case PopupBoxPlacementMode.TopAndAlignLeftEdges:
215227
x = 0 - Math.Abs(offset.X * 3);
216228
y = 0 - popupSize.Height - Math.Abs(offset.Y*2);
@@ -219,6 +231,10 @@ private CustomPopupPlacement[] GetPopupPlacement(Size popupSize, Size targetSize
219231
x = 0 - popupSize.Width + targetSize.Width - offset.X;
220232
y = 0 - popupSize.Height - Math.Abs(offset.Y * 2);
221233
break;
234+
case PopupBoxPlacementMode.TopAndAlignCentres:
235+
x = targetSize.Width / 2 - popupSize.Width / 2;
236+
y = 0 - popupSize.Height - Math.Abs(offset.Y * 2);
237+
break;
222238
default:
223239
throw new ArgumentOutOfRangeException();
224240
}

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@
6363
<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
6464
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
6565
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/>
66+
<Setter Property="PlacementMode" Value="TopAndAlignCentres" />
6667
<Setter Property="HorizontalAlignment" Value="Left" />
6768
<Setter Property="BorderThickness" Value="1"/>
6869
<Setter Property="Cursor" Value="Hand"/>
6970
<Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2" />
70-
<Setter Property="Width" Value="40" />
71-
<Setter Property="Height" Value="40" />
71+
<Setter Property="Width" Value="56" />
72+
<Setter Property="Height" Value="56" />
7273
<Setter Property="Template">
7374
<Setter.Value>
7475
<ControlTemplate TargetType="{x:Type wpf:PopupBox}">

0 commit comments

Comments
 (0)