简体   繁体   English

Xamarin.Forms:绑定到 C#(不是 XAML)中的整个 BindingConext

[英]Xamarin.Forms: Binding to Entire BindingConext in C# (not XAML)

The syntax to bind an item to the entire BindingContext in XAML is {Binding.} .将项目绑定到 XAML 中的整个BindingContext的语法是{Binding.}

How do I do the same in C#?我如何在 C# 中做同样的事情?

The C# equivalent is to {Binding.} is to omit the Binding Path, eg .Bind(Button.CommandParameter) C# 等效于{Binding.}是省略绑定路径,例如.Bind(Button.CommandParameter)

XAML Example XAML 示例

<Button Command="{Binding ButtonCommand}" CommandParameter ="{Binding .}"

Code Example代码示例

using Xamarin.Forms.Markup;

// ...

new Button().Bind(Button.CommandProperty, "ButtonCommand").Bind(Button.CommandParameterProperty)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM