internal bool Close(InfoCard infoCard, InfoCardCloseReason closeReason, bool force) { if ((infoCard == null) || (!infoCard.IsOpen)) { return(false); } // Raise closing event var closingEventArgs = new InfoCardEventArgs(infoCard, InfoCardClosingEvent, this); RaiseEvent(closingEventArgs); infoCard.RaiseClosingEvent(); if (!force && closingEventArgs.Cancel) { return(false); } var notifier = new EventNotifier(); notifier.Subscribe(infoCard); infoCard.Measure(new Size(0, 0)); infoCard.ClearValue(Expander.IsExpandedProperty); infoCard.ClearValue(InfoCard.IsPinnedProperty); var infoCardHost = InfoCardHost.GetInfoCardHost(infoCard); if (infoCardHost != null) { infoCardHost.Content = null; } notifier.RaiseEvents(); if (InfoCardService.GetUnregisterInfoCardOnClose(infoCard)) { InfoCards.Remove(infoCard); } RaiseEvent(new InfoCardEventArgs(infoCard, InfoCardClosedEvent, this)); infoCard.RaiseClosedEvent(); infoCard.LastCloseReason = closeReason; return(true); }
private void RetireInfoCard([NotNull] InfoCard infoCard) { if (infoCard == null) { throw new ArgumentNullException("infoCard"); } infoCard.Closed -= OnInfoCardClosed; infoCard.SubjectChanged -= OnInfoCardSubjectChanged; var infoCardSubject = infoCard.Subject; if (infoCardSubject != null) { _infoCardCache.Remove(infoCard.Subject); } _infoCardCache.RemoveCollectedEntries(); infoCard.ClearValue(InfoCard.SubjectProperty); }