You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 1, 2024. It is now read-only.
The IProvideParentValues interface is useful for custom markup extensions as it allows the extension to inspect the current hierarchy in the visual tree. Currently, when retrieving the current view via IProvideValueTarget.TargetObject, the views Parent is unset, leaving IProvideParentValues as the only way we get a controls parent.
For users of Xamarin.Forms who wish to create custom markup extensions, this means that we are unable to inspect the parent hierarchy for a control. This has been flagged previously by the community in #5052.
API Changes
Change IProvideParentValues accessibility from internal to public.
Intended Use Case
When working with Grids in XAML, we specify the location of a control using the Grid.Row/Grid.Column syntax.
To enable this syntax, the GridLocation and GridSpan must be able to find the parent grid for the IProvideValueTarget.TargetObject. Currently these extensions must use reflection to access this API as there is no obvious alternative.
For a full working prototype of these extensions, and a deeper explanation into their potential benefits, please see:
As a follow up on this request, I've tested my extensions in both compiled and interpreted XAML and there is no difference in behaviour for the IProvideParentValues interface. In both compiled and interpreted XAML the interface behaves the same and returns the same data.
Thanks for this suggestion! As Xamarin.Forms is now in maintenance mode, this will not happen anymore for Xamarin.Forms. We're only adding bugfixes and stability fixes.
If this is still important to you, make sure to check the .NET MAUI repo and see if it's already on the roadmap. If not, feel free to open a discussion to discuss a change first or open an issue with a detailed feature request. Thanks!
Summary
Expose the IProvideParentValues interface as a public API to allow use by third-party markup extensions.
The
IProvideParentValues
interface is useful for custom markup extensions as it allows the extension to inspect the current hierarchy in the visual tree. Currently, when retrieving the current view viaIProvideValueTarget.TargetObject
, the viewsParent
is unset, leavingIProvideParentValues
as the only way we get a controls parent.For users of Xamarin.Forms who wish to create custom markup extensions, this means that we are unable to inspect the parent hierarchy for a control. This has been flagged previously by the community in #5052.
API Changes
Change
IProvideParentValues
accessibility frominternal
topublic
.Intended Use Case
When working with Grids in XAML, we specify the location of a control using the
Grid.Row
/Grid.Column
syntax.By opening up
IProvideParentValues
as a public interface, we can build markup extensions that allow locations and spans to be specified by name:To enable this syntax, the GridLocation and GridSpan must be able to find the parent grid for the
IProvideValueTarget.TargetObject
. Currently these extensions must use reflection to access this API as there is no obvious alternative.For a full working prototype of these extensions, and a deeper explanation into their potential benefits, please see:
The text was updated successfully, but these errors were encountered: