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)
{
view.SetValue(IsRound,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)
{
control.Effects.Remove(effect);
}
}
}
}
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>
</Style>
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!