Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How can use Behaviors in code behind in xamrin form

i am new in Xamarin , i have a question about using behaviors in code behind
i use these code in Xaml and it works fine but i don't know how can i create entry and label in code behind and attach the behaviors to them like Xaml

      <StackLayout ">
                Text="{Binding Title}"
                BackgroundColor="{ DynamicResource PlaceholderColorEntry }"
                PlaceholderColor="{ DynamicResource BaseTextColor }">

                     <validators:EntryEmptyValidatorBehavior x:Name="titleValidator"/>


        <StackLayout Grid.Row="1" Grid.Column="1" >
            <Label HorizontalOptions="Center" >
                        <DataTrigger TargetType="Label"  Binding="{Binding Source={x:Reference titleValidator},Path=IsValid}" Value="False">
                            <Setter Property="Text" Value="{ x:Static fontAwesome:FontAwesomeFont.ExclamationCircle }" />
                            <Setter Property="TextColor" Value="Red" />
                        <DataTrigger TargetType="Label"  Binding="{Binding Source={x:Reference titleValidator},Path=IsValid}" Value="True">
                            <Setter Property="Text" Value="{ x:Static fontAwesome:FontAwesomeFont.CheckCircle }" />
                            <Setter Property="TextColor" Value="Green" />                                   

Best Answers


Sign In or Register to comment.