Bug 37395 - Xamarin.Forms.Xaml.IProvideValueTarget.TargetProperty NotImplemented
Summary: Xamarin.Forms.Xaml.IProvideValueTarget.TargetProperty NotImplemented
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-01-04 22:06 UTC by Ahmed Alejo
Modified: 2017-03-13 08:49 UTC (History)
10 users (show)

Is this bug a regression?: ---
Last known good build:

repro solution (402.64 KB, application/zip)
2016-06-24 23:20 UTC, Jimmy [MSFT]

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Ahmed Alejo 2016-01-04 22:06:20 UTC
Xamarin.Forms.Xaml.Internals.SimpleValueTargetProvider is too simple.

public class OnPlatformExtension : IMarkupExtension
    public object ProvideValue(IServiceProvider serviceProvider)
        var valueTargetProvider = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget));
        //This property access raises a NotImplementedException
        var _ = valueTargetProvider.TargetProperty;
        return null;;
Comment 1 Parmendra Kumar 2016-01-13 16:15:06 UTC

I have checked this issue and I am not sure how to reproduce this issue.
Could you please provide us some steps? so that I can reproduce this issue at my end.

Screencast: http://www.screencast.com/t/JGvwMrQl

Comment 2 adamm 2016-06-21 22:28:45 UTC
If we take a look at the code on Github, it is pretty clear what Ahmed was saying.


public XamlValueTargetProvider(object targetObject, 
                               INode node, 
                               HydratationContext context, 
                               object targetProperty)
	Context = context;
	Node = node;
	TargetObject = targetObject;
	TargetProperty = targetProperty;

INode Node { get; }

HydratationContext Context { get; }

public object TargetObject { get; }

public object TargetProperty
	get { throw new NotImplementedException(); }
	private set { }

There is a very clear Not Implemented Exception in the getter, making it fairly imposisble to use the TargetProperty of the IProvideValueTarget.
Comment 3 Ahmed Alejo 2016-06-22 15:24:17 UTC
This bug is (better, or if, not only) verifiable in xaml code. So i present a pseudo-working-example to reproduce the bug

    public class PropertyNameExtension : IMarkupExtension
        public object ProvideValue(IServiceProvider serviceProvider)
            var valueTargetProvider = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget));
            //This property access raises a NotImplementedException
            var property = valueTargetProvider.TargetProperty;
            return $"{property}";

in xaml:

    <?xml version="1.0" encoding="utf-8" ?>
        <Label Text="{app22:PropertyName}"/><!-- The label should display the string "Text" but a NotImplementedException is raised instead-->
Comment 4 Ahmed Alejo 2016-06-22 15:27:12 UTC
Comment 6 Sam 2016-06-24 08:37:53 UTC
It is indeed very clear in the source code that there is NotImplementedException thrown. This feature is helpful for implementing a custom binding extension.
Comment 7 Jimmy [MSFT] 2016-06-24 23:20:54 UTC
Created attachment 16487 [details]
repro solution

I am able to reproduce the NotImplementedException and have attached a repro solution.

### Steps to Reproduce
1. Run any of the projects inside the repro solution

### Expected Results
The app will launch

### Actual Results
The app throws a NotImplementedException when trying to access TargetProperty

### Tested Info
Tested on Forms 2.3
Comment 8 Stephane Delcroix 2016-12-20 20:26:36 UTC
This is not really a bug, that was an implementation choice.

That being said, it is implemented right now.