【发布时间】:2020-06-13 19:03:42
【问题描述】:
我有一个自定义组件,其中有按钮,我正在尝试创建一个可绑定的命令,以便我可以根据视图模型执行操作。 我尝试了几件事,但似乎没有任何效果:
public static readonly BindableProperty CommandProperty =
BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(MySample), null);
public ICommand Command
{
get { return (ICommand)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}
// Helper method for invoking commands safely
public static void Execute(ICommand command)
{
if (command == null) return;
if (command.CanExecute(null))
{
command.Execute(null);
}
}
【问题讨论】:
标签: c# xamarin xamarin.forms