我想更新我的折旧代码,这里是:
public static readonly BindableProperty CompletedProperty = BindableProperty.CreateAttached<EntryCompletedBehavior, Command>(
bindable => EntryCompletedBehavior.GetCompleted(bindable), /* staticgetter */
null, /* default value */
BindingMode.OneWay, /* defaultBindingMode */
null, /* validateValue */
(b, o, n) => EntryCompletedBehavior.OnCompletedChanged(b, o, n), /* PropertyChanged */
null, /* PropertyChanging */
null); /* CoerceValue */
但我不确定在PropertyName,returnType,declaringType和PropertyChanged中放入什么。我在这里找到了这段代码http://pause.coffee/blog/...,目前以下代码的工作原理是:
public static readonly BindableProperty CompletedProperty = BindableProperty.CreateAttached(
"Completed", /* string PropertyName */
typeof(Command), /* Type returnType */
typeof(Command), /* Type declaringType */
null, /* default value */
BindingMode.OneWay,
null,
(b, o, n) => EntryCompletedBehavior.OnCompletedChanged(b, o, n),
null,
null);
答案 0 :(得分:1)
感谢Bill Reiss; - )
以下代码正在运行:
public static readonly BindableProperty CompletedProperty = BindableProperty.CreateAttached(
"Completed", /* string PropertyName */
typeof(Command), /* Type returnType */
typeof(Entry), /* Type declaringType */
null, /* default value */
BindingMode.OneWay, /* defaultBindingMode */
propertyChanged: (bindable, oldValue, newValue) => {
EntryCompletedBehavior.OnCompletedChanged(bindable, (Command)oldValue, (Command)newValue);
});
答案 1 :(得分:0)
这是一个GitHub链接,指向Charles Petzold更新他的样本以使用非泛型BindableProperty,如果你看它之前和之后应该帮助你。