Visual studio 无法识别 Xamarin 项目中 xaml 中的 RelativeSource Self
Visual studio does not recognise RelativeSource Self in xaml in Xamarin project
我在 documentation 中读到以下示例应该适用于 Xamarin 项目。
<Label Text="{Binding Name}"
HeightRequest="30"
WidthRequest="{Binding Source={RelativeSource Self}, Path=HeightRequest}">
</Label>
但是我的 visual studio(最新的 v2019)将 'RelativeSource Self' 部分标记为红色并给出了以下编译错误:
- 错误 XLS0414 找不到类型 'RelativeSource'。确认您没有缺少程序集引用并且所有引用的程序集都已构建。
- 错误位置20:79。在 xmlns 中找不到类型 RelativeSource http://xamarin.com/schemas/2014/forms
奇怪的是,当打开示例项目时发现 here,visual studio 也以红色显示 'RelativeSource Self' 但确实编译。
我没有在任何地方读到我需要为此包含一个程序集,而 VisualStudio 和 resharper 没有给我包含提示。
OK..更新..我发现我需要将我的 xamarin.forms 引用从 4.1 升级到 4.4 以消除编译警告。
但我觉得奇怪的是 VisualStudio 一直将语句 'RelativeSource Self' 标记为红色。
更新到 Xamarin Forms 4.4.0.991864 解决了我的问题!
微软 Visual Studio 2019
版本 16.5.4
我在 documentation 中读到以下示例应该适用于 Xamarin 项目。
<Label Text="{Binding Name}"
HeightRequest="30"
WidthRequest="{Binding Source={RelativeSource Self}, Path=HeightRequest}">
</Label>
但是我的 visual studio(最新的 v2019)将 'RelativeSource Self' 部分标记为红色并给出了以下编译错误:
- 错误 XLS0414 找不到类型 'RelativeSource'。确认您没有缺少程序集引用并且所有引用的程序集都已构建。
- 错误位置20:79。在 xmlns 中找不到类型 RelativeSource http://xamarin.com/schemas/2014/forms
奇怪的是,当打开示例项目时发现 here,visual studio 也以红色显示 'RelativeSource Self' 但确实编译。
我没有在任何地方读到我需要为此包含一个程序集,而 VisualStudio 和 resharper 没有给我包含提示。
OK..更新..我发现我需要将我的 xamarin.forms 引用从 4.1 升级到 4.4 以消除编译警告。
但我觉得奇怪的是 VisualStudio 一直将语句 'RelativeSource Self' 标记为红色。
更新到 Xamarin Forms 4.4.0.991864 解决了我的问题!
微软 Visual Studio 2019 版本 16.5.4