BindableProperty Cannot resolve property "x" on type "y (property missing or missing accessors)", Am I missing somthing?

Parsa Gachkar 21 Reputation points

I've Implemented an Effect to Make my Entries Round. and it's working if I assign it to my entries. now I'm trying to Implement a global style to automatically assign it to all entries.

According to Microsoft documentation, I need to implement a static Class containing some static Bindable Properties and static Getter Setter Methods to assign and read property values from my Views.

public static class RoundEffect{  
        public static BindableProperty IsRound = BindableProperty.CreateAttached("IsRound",typeof(bool),typeof(RoutingEffect),true,propertyChanged: PropertyChanged);  
        public static bool GetIsRound(BindableObject view)  
            return (bool)view.GetValue(IsRound);  
        public static void SetIsRound(BindableObject view, bool value)  
        private static void PropertyChanged(BindableObject bindable, object oldvalue, object newvalue)  
            var value = (bool) newvalue;  
            var control = bindable as Entry;  
            if (control != null)  
                var effect = control.Effects.FirstOrDefault(q => q is CustomEditTextPlatformEffect);  
                if (value && effect == null)  
                    control.Effects.Add(new CustomEditTextPlatformEffect());  
                else if(!value && effect != null)  

here is the class I've implemented. and I'm trying to use it like this:

<Style TargetType="Entry">  
                <Setter Property="FontFamily" Value="{StaticResource someFont}"></Setter>  
                <Setter Property="effects:RoundEffect.IsRound" Value="True"></Setter>  

I'm getting 0 errors while building but if I try to run it on my android emulator I'm getting this error:

Error	XFC0001	Cannot resolve property "IsRound" on type "RoundEffect (property missing or missing accessors)".  

I'll Really appreciate it if anyone could help me see what am I missing, I've already tried cleaning and rebuilding my solution!

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,253 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kyle Wang 5,526 Reputation points

    Hi ParsaGachkar-5677,

    Welcome to our Microsoft Q&A platform!

    When you create an attached property, you need to append "Property" to your custom property name.

    So in your project, the "IsRound" should be changed to "IsRoundProperty" as follows:

    public static BindableProperty IsRoundProperty =   
                BindableProperty.CreateAttached("IsRound", typeof(bool), typeof(RoundEffect), true, propertyChanged: PropertyChanged);  

    For more info, you can refer to Attached Properties.

    Best Regards,
    Kyle Wang

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful