Error : Object reference not set to an instance of an object, when I build the project.

tousif03razatousif03raza ✭✭INMember ✭✭
edited February 2018 in Xamarin.Forms

Before, I added multitrigger, it was working and there was no error in the Xaml. After, adding multitrigger in the Xaml, it gives the error : Object reference not set to an instance of an object. Can anyone please help me out of this?

Here is my xaml:

    <?xml version="1.0" encoding="UTF-8"?>
    <basePage:BaseContentPage x:Class="LavanyaPlus.EInvitePage" xmlns:local="clr-namespace:LavanyaPlus;assembly:LavanyaPlus" xmlns:fe="clr-namespace:FreshEssentials;assembly=FreshEssentials" x:Name="EInvitePage" Title="Invite" xmlns:basePage="clr-namespace:LavanyaPlus;assembly:LavanyaPlus" xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms">
    <ContentPage.Resources>
    <ResourceDictionary>
         <local:CustomEntryTextLengthConverter x:Key="customEntryTextLengthConverter"/>
        </ResourceDictionary>
        </ContentPage.Resources>
        <ContentPage.Content>      
            <StackLayout x:Name="MainStackLayout" Orientation="Vertical" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" BackgroundColor="#ededed">
                <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="10">
                <local:CornerFrame BackgroundColor="White" OutlineColor="White" HasShadow="true" Padding="5">
                    <local:CustomEntry x:Name="nameEntry" Text="{Binding Name,Mode=TwoWay}" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" Placeholder="Name" BackgroundColor="White">
                    <local:CustomEntry.Behaviors>
                    <local:MandatoryEntryBehavior/>
                            </local:CustomEntry.Behaviors>
                        </local:CustomEntry>
                    </local:CornerFrame>
                    <local:CornerFrame BackgroundColor="White" OutlineColor="White" HasShadow="true" Padding="5" Margin="0,5,0,0">
                    <local:CustomEntry x:Name="emailEntry" Text="{Binding Email,Mode=TwoWay}" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" Placeholder="Email" BackgroundColor="White">
                    <local:CustomEntry.Behaviors>
                    <local:LoginEmailValidatorBehavior/>
                            </local:CustomEntry.Behaviors>
                        </local:CustomEntry>
                    </local:CornerFrame>
                        <local:RoundedButton Text="Invite" Command="{Binding Invite}" HorizontalOptions="FillAndExpand" VerticalOptions="EndAndExpand" BackgroundColor="Green" TextColor="White">
                        <local:RoundedButton.Triggers>
                        <MultiTrigger TargetType="Button">
                            <MultiTrigger.Conditions>
                           <BindingCondition Binding="{Binding Source={x:Reference nameEntry},Path=Text.Length,Converter={StaticResource customEntryTextLengthConverter}}" Value="true"/> 
                           <BindingCondition Binding="{Binding Source={x:Reference emailEntry},Path=Text.Length,Converter={StaticResource customEntryTextLengthConverter}}" Value="true"/> 
                           <Setter Property="IsEnabled" Value="True" />
                                </MultiTrigger.Conditions>
                            </MultiTrigger>
                        </local:RoundedButton.Triggers>
                    </local:RoundedButton>

                </StackLayout>
                </StackLayout>
        </ContentPage.Content>
    </basePage:BaseContentPage>

Answers

  • CharwakaCharwaka ✭✭✭✭✭ INMember ✭✭✭✭✭

    can you put break point in "customEntryTextLengthConverter" and check wether its properly working or not ?

  • tousif03razatousif03raza ✭✭ INMember ✭✭

    @Charwaka I am getting this error, while building the project, not at runtime. How can I check this with a breakpoint?

  • CharwakaCharwaka ✭✭✭✭✭ INMember ✭✭✭✭✭

    @tousif03raza said:
    @Charwaka I am getting this error, while building the project, not at runtime. How can I check this with a breakpoint?

    ok, thn check all namespaces valid or not for you custom button and triggers

  • tousif03razatousif03raza ✭✭ INMember ✭✭

    @Charwaka All namespaces are valid. This is happening, when I added multitrigger. Data trigger was working fine before.

  • CharwakaCharwaka ✭✭✭✭✭ INMember ✭✭✭✭✭
    edited February 2018
        <Button Text="Create" Command="{Binding CreateExpenseCommand}" IsEnabled="false">
                            <Button.Style>
                                <Style TargetType="Button">
                                    <Style.Triggers>
                                        <MultiTrigger TargetType="Button">
                                            <MultiTrigger.Conditions>
                                                <BindingCondition Binding="{Binding Source={x:Reference valueValidator}, Path=IsValid}" Value="True" />
                                                <BindingCondition Binding="{Binding Source={x:Reference typePicker}, Path=SelectedItemProperty, Converter={StaticResource notNull}}" Value="True" />
                                            </MultiTrigger.Conditions>
                                            <Setter Property="IsEnabled" Value="True" />
                                        </MultiTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Button.Style>
                        </Button>
    

    Check this Above Hierarchy modify your code accordingly to replicate above

Sign In or Register to comment.