Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Custom Control and Data Binding

eliseogambaeliseogamba Member ✭✭
edited January 3 in Xamarin.Forms

Hi, when I set value of data binding in field custom, i get this error "No property, bindable property, or event found for 'ActivedEffect', or mismatching type between value and property."

My custom control:

    namespace App.Customers
    {
    class EffectFrame :  Frame
    {
        public BindableProperty ActivedEffectPropiety = BindableProperty.Create(nameof(ActivedEffect),
                                                                            typeof(bool),
                                                                            typeof(EffectFrame),
                                                                            false,
                                                                            BindingMode.TwoWay);
    public bool ActivedEffect
    {
        get
        {
            return (bool)GetValue(ActivedEffectPropiety);
        }
        set
        {
            SetValue(ActivedEffectPropiety, value);
        }
    }

    protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        if (propertyName.Equals(nameof(ActivedEffect)))
        {
            if (ActivedEffect)
            {
                this.FadeTo(1, 500);
            }
            else
            {
                this.FadeTo(0, 500);
            }
        }


        base.OnPropertyChanged(propertyName);
        }

    }
}

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
         xmlns:Image="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
         xmlns:Custom="clr-namespace:App.Customers"
         x:Class="App.Views.Example">
<StackLayout>
    <Custom:EffectFrame  BackgroundColor="White" 
                         VerticalOptions="End" 
                         HorizontalOptions="FillAndExpand"
                         CornerRadius="10"
                         Margin="23,0,23,14"
                         Padding="0"
                         ActivedEffect="{Binding InfoVisible}">
        <StackLayout Spacing="0">
            <StackLayout Orientation="Horizontal"
                         Margin="26,22,0,0">
                <Label Text="Text"
                       TextColor="#ED1C24"
                       FontSize="15">
                </Label>
            </StackLayout>    
        </Custom:EffectFrame>
    </StackLayout>
</ContentPage>

The field "InfoVisbile" is a bool in ViewModel

Any idea?

Best Answer

Answers

Sign In or Register to comment.