I am trying to use Dependency Property in Maui, but it looks like it is not available with Maui. It is showing reference missing error. How can I resolve it? Same code is working in xamarin and uwp but in Maui it is showing reference error for DependencyProperty keyword.
Following is the code example:
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))
);
We can use BindableProperty at place of 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)
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.