1
votes

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:

  • Error XLS0414 The type 'RelativeSource' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
  • Error Position 20:79. Type RelativeSource not found in xmlns http://xamarin.com/schemas/2014/forms

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.

1
If the compiler builds successfully, it would be no problem , try to restart your pc and ide to check if error persists.ColeX - MSFT
rebooting does not resolve the issueSjors Miltenburg

1 Answers

0
votes

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

Microsoft Visual Studio 2019 Version 16.5.4