Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Custom Control and Data Binding

$
0
0

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?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>