我正在尝试在毛伊岛使用依赖属性,但它似乎不适用于毛伊岛。它显示参考缺失错误。我该如何解决?相同的代码在 xamarin 和 uwp 中工作,但在毛伊岛它显示 DependencyProperty 关键字的引用错误。
以下是代码示例:
public static CornerRadius GetCornerRadius(Button element)
{
return (CornerRadius)element.GetValue(CornerRadiusProperty);
}
public static readonly DependencyProperty CornerRadiusProperty =
DependencyProperty.RegisterAttached(
"CornerRadius",
typeof(CornerRadius),
typeof(ButtonHelperClass),
new PropertyMetadata(new CornerRadius(5))
);
Run Code Online (Sandbox Code Playgroud)
我们可以使用 BindableProperty 代替 DependencyProperty
public static CornerRadius GetCornerRadius(Button element)
{
return (CornerRadius)element.GetValue(CornerRadiusProperty);
}
public static readonly BindableProperty CornerRadiusProperty =
BindableProperty.CreateAttached(
"CornerRadius",
typeof(CornerRadius),
typeof(ButtonHelperClass),
new CornerRadius(5)
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1907 次 |
| 最近记录: |