Skip to content

Commit aef084c

Browse files
committed
fix conflict
2 parents 04e7dd5 + 640a129 commit aef084c

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

MainDemo.Wpf/Buttons.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@
8080
<materialDesign:PopupBox Style="{StaticResource MaterialDesignMultiFloatingActionPopupBox}"
8181
PlacementMode="BottomAndAlignCentres"
8282
ToolTipService.Placement="Right"
83-
ToolTip="PopupBox, Style MaterialDesignMultiFloatingActionPopupBox">
83+
ToolTip="PopupBox, Style MaterialDesignMultiFloatingActionPopupBox"
84+
OnPopupOpened="PopupBox_OnPopupOpened"
85+
OnPopupClosed="PopupBox_OnPopupClosed">
8486
<StackPanel>
8587
<Button ToolTip="One">1</Button>
8688
<Button ToolTip="Two">2</Button>

MainDemo.Wpf/Buttons.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,15 @@ private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
3939
{
4040
Console.WriteLine("Just checking we haven't suppressed the button.");
4141
}
42+
43+
private void PopupBox_OnPopupOpened(object sender, RoutedEventArgs e)
44+
{
45+
Console.WriteLine("Just making sure the popup has opened.");
46+
}
47+
48+
private void PopupBox_OnPopupClosed(object sender, RoutedEventArgs e)
49+
{
50+
Console.WriteLine("Just making sure the popup has closed.");
51+
}
4252
}
4353
}

MaterialDesignThemes.Wpf/PopupBox.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,25 @@ private static void IsPopupOpenPropertyChangedCallback(DependencyObject dependen
242242
else
243243
Mouse.Capture(null);
244244
}
245+
246+
if (newValue)
247+
{
248+
var popupOpenedEventArgs = new RoutedEventArgs()
249+
{
250+
RoutedEvent = OnPopupOpenedEvent,
251+
Source = popupBox
252+
};
253+
popupBox.RaiseEvent(popupOpenedEventArgs);
254+
}
255+
else
256+
{
257+
var popupClosedEventArgs = new RoutedEventArgs()
258+
{
259+
RoutedEvent = OnPopupClosedEvent,
260+
Source = popupBox
261+
};
262+
popupBox.RaiseEvent(popupClosedEventArgs);
263+
}
245264

246265
popupBox.AnimateChildrenIn(!newValue);
247266
popupBox._popup?.RefreshPosition();
@@ -258,6 +277,45 @@ public bool IsPopupOpen
258277
set { SetValue(IsPopupOpenProperty, value); }
259278
}
260279

280+
/// <summary>
281+
/// Event corresponds to the popup opening
282+
/// </summary>
283+
public static readonly RoutedEvent OnPopupOpenedEvent =
284+
EventManager.RegisterRoutedEvent(
285+
"OnPopupOpened",
286+
RoutingStrategy.Bubble,
287+
typeof(RoutedEventHandler),
288+
typeof(PopupBox));
289+
290+
/// <summary>
291+
/// Event corresponds to the popup closing
292+
/// </summary>
293+
public static readonly RoutedEvent OnPopupClosedEvent =
294+
EventManager.RegisterRoutedEvent(
295+
"OnPopupClosed",
296+
RoutingStrategy.Bubble,
297+
typeof(RoutedEventHandler),
298+
typeof(PopupBox));
299+
300+
/// <summary>
301+
/// Add / Remove OnPopupOpenedEvent handler
302+
/// </summary>
303+
public event RoutedEventHandler OnPopupOpened
304+
{
305+
add { AddHandler(OnPopupOpenedEvent, value); }
306+
remove { RemoveHandler(OnPopupOpenedEvent, value); }
307+
}
308+
309+
/// <summary>
310+
/// Add / Remove OnPopupClosedEvent handler
311+
/// </summary>
312+
public event RoutedEventHandler OnPopupClosed
313+
{
314+
add { AddHandler(OnPopupClosedEvent, value); }
315+
remove { RemoveHandler(OnPopupClosedEvent, value); }
316+
}
317+
318+
261319
public static readonly DependencyProperty StaysOpenProperty = DependencyProperty.Register(
262320
nameof(StaysOpen), typeof (bool), typeof (PopupBox), new PropertyMetadata(default(bool)));
263321

0 commit comments

Comments
 (0)