【问题标题】:The property 'CalculateCommand' was not found in type 'ContentPage' Xamarin Forms在类型“ContentPage”Xamarin Forms 中找不到属性“CalculateCommand”
【发布时间】:2021-10-11 05:51:30
【问题描述】:

我遇到了 BindableProperty 的这个问题,我正在做一个 GPS 项目,但我找不到解决方案 imageFromMyProjectHere

【问题讨论】:

  • 您已将 DataContext 设置为 MapViewModel,因此它正在寻找 ICommand 属性,而不是在后面的代码中。将来也请在您的问题中提供实际代码。截图中断,截图无法复制粘贴...
  • 欢迎使用 stackoverflow。请包括代码、错误消息和其他基于文本的信息作为文本,而不是屏幕截图。我推荐taking the tour,以及阅读how to ask a good questionwhat's on topic

标签: c# xamarin xamarin.forms visual-studio-2019 bindableproperty


【解决方案1】:

CaculateCommand 不是 ContentPage 的属性造成的。

您可以在其他页面访问。

第 14 页:其中包括 CaculateCommand 属性。

   public partial class Page14 : ContentPage
{

    public static readonly BindableProperty CaculateCommandProperty = BindableProperty.Create(nameof(CaculateCommand), typeof(Command), typeof(Page14), null, propertyChanged: HandleCaculateCommandChanged);

    private static void HandleCaculateCommandChanged(BindableObject bindable, object oldValue, object newValue)
    {

    }
    public Command CaculateCommand
    {
        get => (Command)GetValue(CaculateCommandProperty);
        set => SetValue(CaculateCommandProperty, value);
    }
     
     //........
}

Page15.cs:

   public partial class Page15 : Page14

第15页xaml:

  <local:Page14  xmlns:local="clr-namespace:App14" xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
           x:Class="App14.Page15"
          CaculateCommand="{Binding CaculateRouteCommand}">

  </local:Page14>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-13
    • 2018-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多