protected override void OnAttached() { var triggers = Interaction_ .GetTriggers(AssociatedObject) .OfType <EventTrigger>(); var actions = triggers .First(t => t.EventName == "Closing") .Actions .OfType <InvokeCommandAction>(); _commandAction = actions.First(); AssociatedObject.Closing += _windowClosingHandler; }