Skip to content

Commit 2d6167b

Browse files
committed
Improve PopupBox.StaysOpen fixes #241
1 parent d3400e4 commit 2d6167b

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

MainDemo.Wpf/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@
182182
<DockPanel>
183183
<ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}" IsChecked="False"
184184
x:Name="MenuToggleButton"/>
185-
<materialDesign:PopupBox DockPanel.Dock="Right" PlacementMode="BottomAndAlignRightEdges">
185+
<materialDesign:PopupBox DockPanel.Dock="Right" PlacementMode="BottomAndAlignRightEdges" StaysOpen="True">
186186
<StackPanel>
187187
<Button Content="Hello World" Click="MenuPopupButton_OnClick"/>
188188
<Button Content="Nice Popup" Click="MenuPopupButton_OnClick"/>
189-
<Button Content="Goodbye" Click="MenuPopupButton_OnClick"/>
189+
<Button Content="Goodbye" Click="MenuPopupButton_OnClick"/>
190190
</StackPanel>
191191
</materialDesign:PopupBox>
192192
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="22">Material Design In XAML Toolkit</TextBlock>

MaterialDesignThemes.Wpf/PopupBox.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,14 @@ public DataTemplate PopupContentTemplate
214214
set { SetValue(PopupContentTemplateProperty, value); }
215215
}
216216

217+
[Obsolete]
217218
public static readonly DependencyProperty StaysOpenOnEditProperty = DependencyProperty.Register(
218219
nameof(StaysOpenOnEdit), typeof (bool), typeof (PopupBox), new PropertyMetadata(default(bool)));
219220

220221
/// <summary>
221-
/// Indicates if the opup should stay open after a click is made inside the popup.
222+
/// Prefer <see cref="StaysOpen"/>.
222223
/// </summary>
224+
[Obsolete]
223225
public bool StaysOpenOnEdit
224226
{
225227
get { return (bool) GetValue(StaysOpenOnEditProperty); }
@@ -585,7 +587,7 @@ private static void OnLostMouseCapture(object sender, MouseEventArgs e)
585587
if (e.OriginalSource == popupBox)
586588
{
587589
if (Mouse.Captured == null || popupBox._popup == null || !(Mouse.Captured as DependencyObject).IsDescendantOf(popupBox._popup))
588-
{
590+
{
589591
popupBox.Close();
590592
}
591593
}
@@ -601,8 +603,9 @@ private static void OnLostMouseCapture(object sender, MouseEventArgs e)
601603
}
602604
}
603605
else
604-
{
605-
popupBox.Close();
606+
{
607+
if (!popupBox.StaysOpen)
608+
popupBox.Close();
606609
}
607610
}
608611
}

0 commit comments

Comments
 (0)