Describe the bug
The attached properties for the "relative ancestor" feature are currently targeting the wrong type:
https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/44ad0cc6806c99f1a693c923cb94ea7551718c13/Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement/FrameworkElementExtensions.RelativeAncestor.cs#L18-L21
These are defined in FrameworkElementExtensions but target a DependencyObject. This is not correct on its own, but in particular it also makes the APIs technically more error prone, as there is no type guarantee at build-time, and we're doing additional checks at runtime to ensure the input elements are in fact FrameworkElement-s, otherwise we do nothing:
https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/44ad0cc6806c99f1a693c923cb94ea7551718c13/Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement/FrameworkElementExtensions.RelativeAncestor.cs#L62-L65
Given that these APIs only make sense for FrameworkElement instances, and that they're defined within FrameworkElementExtensions too, we should update the signature and have them only target FrameworkElement objects. I should note: this would not be a source breaking change when the API was being used correctly, but it would be a binary breaking change.
Describe the bug
The attached properties for the "relative ancestor" feature are currently targeting the wrong type:
https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/44ad0cc6806c99f1a693c923cb94ea7551718c13/Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement/FrameworkElementExtensions.RelativeAncestor.cs#L18-L21
These are defined in
FrameworkElementExtensionsbut target aDependencyObject. This is not correct on its own, but in particular it also makes the APIs technically more error prone, as there is no type guarantee at build-time, and we're doing additional checks at runtime to ensure the input elements are in factFrameworkElement-s, otherwise we do nothing:https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/44ad0cc6806c99f1a693c923cb94ea7551718c13/Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement/FrameworkElementExtensions.RelativeAncestor.cs#L62-L65
Given that these APIs only make sense for
FrameworkElementinstances, and that they're defined withinFrameworkElementExtensionstoo, we should update the signature and have them only targetFrameworkElementobjects. I should note: this would not be a source breaking change when the API was being used correctly, but it would be a binary breaking change.