Does Not exist in current context?!

KeithnoloKeithnolo Member ✭✭
edited November 2018 in Xamarin.Forms

Hi Guys
My xaml.cs page is not picking up the "x:name" of my button in the Mainpage.xaml class, has anyone any idea why I'm getting this error? I will post the code below.
Thanks a million for any help!!!!!

MainPage.xaml:

<?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:local="clr-namespace:VideoPlayer"
             xmlns:forms="clr-namespace:Plugin.MediaManager.Forms;assembly=Plugin.MediaManager.Forms"
             x:Class="VideoPlayer.MainPage">

    <StackLayout>
        <forms:VideoView WidthRequest="360"
                     HeightRequest="202"
                     />
        <Button x:Name ="PlayStop"
            Text="Play"
            Clicked= "Button_Clicked">            
        </Button>

</StackLayout>

MainPage.xaml.cs

using Plugin.MediaManager;
using Plugin.MediaManager.Abstractions.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace VideoPlayer
{
    public partial class MainPage : ContentPage
    {
        String videoUrl = "https://www.youtube.com/watch?v=kZ-eFt5kSSQ";
        public MainPage()
        {             
            InitializeComponent();
        }

        private void PlayStop_Clicked(object sender, EventArgs e)
        {
            Error ---->           
            if (PlayStop.Text == "Play")
            {
                CrossMediaManager.Current.Play(videoUrl, MediaFileType.Video);
            };
        }
    }
}

Best Answer

Answers

Sign In or Register to comment.