| 25 | wux::PropertyMetadata(nullptr, OnAncestorTypeChanged)); |
| 26 | |
| 27 | void RelativeAncestor::OnAncestorTypeChanged(const wux::DependencyObject &d, const wux::DependencyPropertyChangedEventArgs &e) |
| 28 | { |
| 29 | if (const auto fe = d.try_as<wux::FrameworkElement>()) |
| 30 | { |
| 31 | RemoveHandlers(fe); |
| 32 | |
| 33 | if (e.NewValue()) |
| 34 | { |
| 35 | event_token unloadedToken = fe.Unloaded(OnFrameworkElementUnloaded); |
| 36 | try |
| 37 | { |
| 38 | s_UnloadedTokenList.push_back({ fe, unloadedToken }); |
| 39 | } |
| 40 | catch (...) |
| 41 | { |
| 42 | // just in case something happens |
| 43 | fe.Unloaded(unloadedToken); |
| 44 | throw; |
| 45 | } |
| 46 | |
| 47 | event_token loadedToken = fe.Loaded(OnFrameworkElementLoaded); |
| 48 | try |
| 49 | { |
| 50 | s_LoadedTokenList.push_back({ fe, loadedToken }); |
| 51 | } |
| 52 | catch (...) |
| 53 | { |
| 54 | // just in case something happens |
| 55 | fe.Unloaded(unloadedToken); |
| 56 | fe.Loaded(loadedToken); |
| 57 | throw; |
| 58 | } |
| 59 | |
| 60 | if (fe.Parent()) |
| 61 | { |
| 62 | OnFrameworkElementLoaded(fe, nullptr); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | void RelativeAncestor::OnFrameworkElementLoaded(const wf::IInspectable &sender, const wux::RoutedEventArgs &) |
| 69 | { |
nothing calls this directly
no outgoing calls
no test coverage detected