I have a problem with an Entry object in my Xamarin.Forms App.
When I use the app on an Android device, there is no problem. I can enter a text in it and then use this text on a ButtonPressed
event. But on UWP App I have a null reference on my Entry
Object. Here you can find my code and the excpetion :
[using Xamarin.Forms.Xaml;
namespace XamarinTest2.views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Search : ContentPage
{
public Search ()
{
InitializeComponent();
Vid.Text = "lol";
}
void SearchVideo(Object sender)
{
Application.Current.MainPage = new PageFeedYouTube(Vid.Text);
//This line throws NullReferenceException on Vid
}
And here my xaml view :
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamarinTest2.views.Search"
Title="Recherche">
<ContentPage.Content>
<StackLayout>
<Label Text="Recherche YouTube!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
<Entry Placeholder="Video" Text="" IsVisible="True" IsEnabled="True" IsPassword="True" x:Name="Vid"/>
<Button Text="Recherche" Pressed="SearchVideo" />
</StackLayout>
</ContentPage.Content>
I'm a little lost, why does my Entry doesn't work in my UWP App?
Text
lol
in constructorVid
is notnull
?