visual-studioxamarinbindingrelativesource

Visual studio does not recognise RelativeSource Self in xaml in Xamarin project


I read in the documentation that the following example should work in a Xamarin project.

<Label Text="{Binding Name}" 
       HeightRequest="30" 
       WidthRequest="{Binding Source={RelativeSource Self}, Path=HeightRequest}">
</Label>

But my visual studio (up to date v2019) marks the 'RelativeSource Self' part in red and gives me the following compile errors:

Weirdly enough, when opening the sample project found here, visual studio also shows 'RelativeSource Self' in red but does compile.

I have not read anywhere that I need to include an assembly for this and VisualStudio and resharper don't give me include hints.

OK.. UPDATE .. I found out that I needed to upgrade my xamarin.forms references from 4.1 to 4.4 to get rid of the compile warnings.

But I find it odd that VisualStudio keeps marking the statement 'RelativeSource Self' in red.


Solution

  • Update to Xamarin Forms 4.4.0.991864 solved the issue in my place!

    Microsoft Visual Studio 2019 Version 16.5.4