PrismLibrary/Prism · error · Exception

is not supported

Error message

{valueTargetProvider.TargetObject} is not supported

What it means

Prism's XAML markup extensions (e.g. Bind, ViewModelLocator) need to resolve the target element they are applied to in order to find the parent page. ProvideValue throws this exception when the service provider does not yield a supported target (neither a BindableElement nor a Behavior's AssociatedObject), so the extension has no element context to work with.

Solutions

  1. Move the markup extension so it is applied directly to a bindable VisualElement property, not a Style/Setter or resource value.
  2. If used inside a behavior, ensure the behavior derives from BehaviorBase<BindableObject> and its AssociatedObject is a VisualElement.
  3. Wrap usage in OnPlatform/OnIdiom only at the element property level, keeping the extension attached to an element.
  4. If the element is attached later, rely on the ElementParentedCallbackBehavior fallback by ensuring TargetElement is resolvable at ProvideValue time.

Example fix

<!-- before -->
<Style TargetType="Label">
  <Setter Property="Text" Value="{prism:Bind Name}" />
</Style>
<!-- after -->
<Label Text="{prism:Bind Name}" />
Defensive patterns

Strategy: validation

Validate before calling

if (targetObject is VisualElement || targetObject is BehaviorBase<BindableObject>)
    myExtension.Apply();
else
    throw new InvalidOperationException($"{targetObject} is not supported");

Type guard

bool IsSupportedTarget(object target) => target is VisualElement || target is BehaviorBase<BindableObject> b && b.AssociatedObject is VisualElement;

Prevention

When it happens

Trigger: Using an extension such as x:Bind-style Prism markup extension in a context where IProvideValueTarget.TargetObject is neither a bindable VisualElement nor a BehaviorBase<BindableObject> (e.g. applied to a resource dictionary entry, a Setter value, or a non-VisualElement target). Also occurs when the extension is used inside a behavior whose AssociatedObject is not a VisualElement.

Common situations: Applying the extension in a Style Setter or DataTrigger where there is no target element; using it inside custom behaviors that do not derive from BehaviorBase<BindableObject>; platform-specific layouts where the target object is a different wrapper type.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15). Data as JSON: /api/errors/bbe137c42dcdb604. Report an issue: GitHub.

Appendix: source

Thrown at src/Maui/Prism.Maui/Xaml/TargetAwareExtensionBase.cs:87

    /// <param name="serviceProvider">The service provider for the markup extension.</param>
    /// <returns>The value to set on the property where the extension is applied.</returns>
    /// <exception cref="ArgumentException">Thrown if the service provider does not provide an <see cref="IProvideValueTarget"/>.</exception>
    /// <exception cref="Exception">Thrown if the target object is not supported.</exception>
    T IMarkupExtension<T>.ProvideValue(IServiceProvider serviceProvider)
    {
        var valueTargetProvider = serviceProvider.GetService<IProvideValueTarget>();

        if (valueTargetProvider == null)
            throw new ArgumentException(Resources.ServiceProviderDidNotHaveIProvideValueTarget);

        TargetElement = valueTargetProvider.TargetObject as VisualElement;

        //this is handling the scenario of the extension being used within the EventToCommandBehavior
        if (TargetElement is null && valueTargetProvider.TargetObject is BehaviorBase<BindableObject> behavior)
            TargetElement = behavior.AssociatedObject as VisualElement;

        if (TargetElement is null)
            throw new Exception($"{valueTargetProvider.TargetObject} is not supported");

        if (TargetElement.TryGetParentPage(out var page))
            Page = page;
        else
            TargetElement.Behaviors.Add(new ElementParentedCallbackBehavior(() => Page = TargetElement.GetParentPage()));

        return ProvideValue(serviceProvider);
    }

    /// <summary>
    /// Provides the value for the markup extension (non-generic implementation).
    /// </summary>
    /// <param name="serviceProvider">The service provider for the markup extension.</param>
    /// <returns>The value to set on the property where the extension is applied.</returns>
    object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) =>
        ((IMarkupExtension<T>)this).ProvideValue(serviceProvider);

    /// <summary>

View on GitHub (pinned to 358118cd64)