Reputation: 1459
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))
);
Upvotes: 3
Views: 2644
Reputation: 1459
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)
);
Upvotes: 8