public void SetNotificationContent(BaseNotificationContentControl control, bool alreadyLoaded = false) { ContentControl.Content = control; var buttons = Notification?.Actions?.Select(c => new NotificationActionButton(c)) ?? Enumerable.Empty <NotificationActionButton>(); var actionButtons = buttons as NotificationActionButton[] ?? buttons.ToArray(); ActionPanel.Children.Clear(); using (var d = Dispatcher.DisableProcessing()) { foreach (var button in actionButtons) { ActionPanel.Children.Add(button); } } if (!alreadyLoaded) { var onLoaded = PrepareWindow(control, actionButtons); Loaded -= onLoaded; Loaded += onLoaded; } else { using (var d = Dispatcher.DisableProcessing()) { AdjustWindowToContentControl(control); PrepareButtons(actionButtons); } } }
public RoutedEventHandler PrepareWindow(BaseNotificationContentControl control, NotificationActionButton[] actionButtons) { return((sender, args) => { using (Dispatcher.DisableProcessing()) { Hide(); PrepareButtons(actionButtons); AdjustWindowToContentControl(control); PrepareWindowLocation(); Show(); } }); }