1
resposta

Meu projeto está com seguinte erro!!!

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage  xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="ProjetoWebForms.Views.MasterView"
             xmlns:view="clr-namespace:ProjetoWebForms.Views"
             Title="usuário">
    <Frame OutlineColor="Silver"
           VerticalOptions="CenterAndExpand"
           Margin="15">
        <StackLayout HorizontalOptions="Center" >
            <Label Text="{Binding Nome}"></Label>
            <BoxView HeightRequest="1" HorizontalOptions="Fill"></BoxView>
            <Label Text="{Binding Email}"></Label>
            <BoxView HeightRequest="1" HorizontalOptions="Fill"></BoxView>
            <Button Text="Perfil"></Button>
        </StackLayout>
    </Frame>
</TabbedPage>
public partial class MasterView : TabbedPage
    {


        public MasterView (Usuario usuario)
        {
            InitializeComponent ();

            this.BindingContext = new MasterViewModel(usuario);
        }
    }

Erro

Unhandled Exception:

System.InvalidCastException: Specified cast is not valid.
1 resposta

Olá, Manasses

Verifique o tipo destas propriedades. Veja se elas são realmente string:

  • MasterViewModel.Nome
  • MasterViewModel.Email

Além disso, verifique se o namespace do code behind da MasterView é o mesmo da view (`ProjetoWebForms.Views.MasterView)

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software