VerticalOptions is cant be found or mismatch type between value or property

47 Views Asked by At

Severity Code Description Project File Line Suppression State Error XFC0009 No property, BindableProperty, or event found for "VerticalOptions", or mismatching type between value and property. NetflixCloneApp

I am creating a netflix clone app on visual studio and I have specified a bindable property which i'll be using in my main page but the verticaloptions view is not working with the property.

This is My MovieInfoBox.xaml.cs

using NetflixCloneApp.Models;

namespace NetflixCloneApp.Controls;

public partial class MovieInfoBox : ContentPage
{
    public static readonly BindableProperty MediaProperty =
        BindableProperty.Create(nameof(Media), typeof(Media), typeof(MovieInfoBox), null);
    public MovieInfoBox()
    {
        InitializeComponent();
    }

    public Media Media 
    { get => (Media)GetValue(MovieInfoBox.MediaProperty); 
      set => SetValue(MovieInfoBox.MediaProperty, value);
    }
}

This is My Models Class

using CommunityToolkit.Mvvm.ComponentModel;
using NetflixCloneApp.Models;
using NetflixCloneApp.Services;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NetflixCloneApp.ViewModels
{
    public partial class HomeViewModel : ObservableObject
    {
        private readonly TmdbService _tmdbService;
        public HomeViewModel(TmdbService tmdbService)
        {
            _tmdbService = tmdbService;
        }
        [ObservableProperty]
        private Media _trendingMovie;

        [ObservableProperty]
        private Media _selectedMedia;
        public ObservableCollection<Media> Trending { get; set; } = new();
        public ObservableCollection<Media> TopRated { get; set; } = new();
        public ObservableCollection<Media> NetflixOriginals { get; set; } = new();
        public ObservableCollection<Media> ActionMovies { get; set; } = new();

        public async Task InitializeAsync()
        {
            var trendingListTask =  _tmdbService.GetTrendingAsync();
            var netflixOriginalsListTask =  _tmdbService.GetNetflixOriginalsAsync();
            var topRatedListTask =  _tmdbService.GetTopRatedAsync();
            var actionListTask =  _tmdbService.GetActionAsync();

            var medias = await Task.WhenAll(trendingListTask,
                                            netflixOriginalsListTask,
                                            topRatedListTask,
                                            actionListTask);

            var trendingList = medias[0];
            var netflixOriginalsList = medias[1];
            var topRatedList = medias[2];
            var actionList = medias[3];

            TrendingMovie = trendingList.OrderBy(t => Guid.NewGuid())
                               .FirstOrDefault(t => 
                               !string.IsNullOrWhiteSpace(t.DisplayTitle)
                               && !string.IsNullOrWhiteSpace(t.Thumbnail));



            SetMediaCollection(trendingList, Trending);
            SetMediaCollection(netflixOriginalsList, NetflixOriginals);
            SetMediaCollection(topRatedList, TopRated);
            SetMediaCollection(actionList, ActionMovies);

            SelectedMedia = TrendingMovie;


        }
        private static void SetMediaCollection(IEnumerable<Media> medias, ObservableCollection<Media> collecion)
        {
            collecion.Clear();
            foreach (var media in medias)
            {
                collecion.Add(media);
            }
        }
    }
}

This is the MainPage Class

<controls:MovieInfoBox Media="{Binding SelectedMedia}"
                               VerticalOptions="End"></controls:MovieInfoBox>

Error Description

0

There are 0 best solutions below