Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Switch control throws Java.Lang.NullPointerException

$
0
0

Hi guys.
I want to add switch control to XAML:
<Switch IsToggled="{Binding IsAdult}" />

Here is my XAML file (I
<ContentPage.Content>







            <StackLayout Orientation="Horizontal" HorizontalOptions="Center">
                <Image 
                    Source="nick_icon.png" 
                    WidthRequest="30"
                    HeightRequest="30" />
                <Entry 
                    Placeholder="Nazwa użytkownika" 
                    FontSize="Default"/>
            </StackLayout>

            <StackLayout Orientation="Horizontal" HorizontalOptions="Center">
                <Label Text="Jestem osobą pełnoletnią"/>
                <Switch IsToggled="{Binding IsAdult}" />
            </StackLayout>

            <customs:RoundedSendButton 
                HorizontalOptions="Center"
                Text="SIGN UP" 
                TextColor="White"
                BackgroundColor="#f3b197"
                Margin="20, 0">
            </customs:RoundedSendButton>
        </StackLayout>
    </ScrollView>
</ContentPage.Content>

I inject ViewModel which works. When I run this in Android Emulator on Windows then I get:

Java.Lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference

I also tried:
<ContentPage.Content><Switch IsToggled="{Binding IsAdult}" /></ContentPage.Content>

So, the problem is related with . I tried to find something on the Internet, but I've not found a solution.

Do you know how to resolve it?


Viewing all articles
Browse latest Browse all 204402

Trending Articles