Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Login Erro

Desde que eu implementei as mudanças da aula 8 do curso xamarin 3, toda vez que eu vou fazer o login aparecem os seguintes erros

System.Reflection.TargetInvocationException
Xamarin.Forms.Xaml.XamlParseException
Position 38:47. Cannot assign property "Command": Property does not exists, or is not assignable, or mismatching type between value and property
namespace TesteDrive.Views
{
    public partial class MasterView : TabbedPage
    {
        public MasterView(Usuario usuario)
        {
            InitializeComponent();
            this.BindingContext = new MasterViewModel(usuario);
            BackgroundColor = Color.SkyBlue; // cor background master detail page
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();
            SalvarMenssagens();
        }

        protected override void OnDisappearing()
        {
            base.OnDisappearing();
            CancelarMensagens();
        }

        private void SalvarMenssagens()
        {
            MessagingCenter.Subscribe<Usuario>(this, "EditarPerfil",
                (obj) =>
                {
                    this.CurrentPage = this.Children[1];
                });

            MessagingCenter.Subscribe<Usuario>(this, "SucessoSalvarUsuario",
                (obj) =>
                {
                    this.CurrentPage = this.Children[0];
                });
        }

        private void CancelarMensagens()
        {
            MessagingCenter.Unsubscribe<Usuario>(this, "EditarPerfil");

            MessagingCenter.Unsubscribe<Usuario>(this, "SucessoSalvarUsuario");
        }
    }
}
namespace TesteDrive.ViewModels
{
    public class MasterViewModel
    {
        public string Nome
        {
            get { return this.usuario.nome; }
            set { this.usuario.nome = value; }
        }

        public string Telefone
        {
            get { return this.usuario.telefone; }
            set { this.usuario.telefone = value; }
        }

        public string DataNascimento
        {
            get { return this.usuario.dataNascimento; }
            set { this.usuario.dataNascimento = value; }
        }

        public string Email
        {
            get { return this.usuario.email; }
            set { this.usuario.email = value; }
        }

        private readonly Usuario usuario;

        public ICommand EditarPerfilCommand { get; private set; }
        public ICommand SalvarPerfilCommand { get; private set; }

        public MasterViewModel(Usuario usuario)
        {
            this.usuario = usuario;
            DefinirComandos(usuario);
        }

        private void DefinirComandos(Usuario usuario)
        {
            EditarPerfilCommand = new Command(
                () =>
                {
                    MessagingCenter.Send<Usuario>(usuario, "EditarPerfil");
                });

            SalvarPerfilCommand = new Command(
                () =>
                {
                    MessagingCenter.Send<Usuario>(usuario, "SucessoSalvarUsuario");
                });
        }
    }
}
namespace TesteDrive.Views
{
    public partial class MasterDetailView : MasterDetailPage
    {
        private readonly Usuario usuario;
        public MasterDetailView(Usuario usuario)
        {
            InitializeComponent();
            this.usuario = usuario;
            this.Master = new MasterView(usuario);
        }
    }
}
<?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="TesteDrive.Views.MasterView"
    Title="Perfil">

    <TabbedPage.Children>
        <ContentPage Title="USUÁRIO">
            <Frame OutlineColor="Silver"
                Margin="15"
                VerticalOptions="CenterAndExpand"
                BackgroundColor="Gray">
                <StackLayout HorizontalOptions="Center" VerticalOptions="Center">
                    <Label Text="{Binding Nome}"></Label>
                    <BoxView HeightRequest="1" HorizontalOptions="Fill" Color="Gray"></BoxView>
                    <Label Text="{Binding Email}"></Label>
                    <BoxView HeightRequest="1" HorizontalOptions="Fill" Color="Gray"></BoxView>
                    <Button Text="PERFIL" Command="{Binding EditarPerfilCommand}"></Button>
                </StackLayout>
            </Frame>
        </ContentPage>
        <ContentPage Title="EDITAR">
            <Frame OutlineColor="Silver"
                    Margin="15"
                    VerticalOptions="CenterAndExpand"
                    BackgroundColor="Gray">
                    <StackLayout HorizontalOptions="Center" VerticalOptions="Center">
                        <TableView>
                            <TableRoot>
                                <TableSection Title="Dados Pessoais">
                                    <EntryCell Placeholder="Nome" Text="{Binding Nome}"></EntryCell>
                                    <EntryCell Placeholder="Data de Nascimento" Text="{Binding DataNascimento}"></EntryCell>
                                    <EntryCell Placeholder="Telefone" Text="{Binding Telefone}"></EntryCell>
                                    <EntryCell Placeholder="Email" Text="{Binding Email}"></EntryCell>
                                </TableSection>
                            </TableRoot>
                        </TableView>
                        <Button Text="SALVAR" Command="SalvarPerfilCommand"></Button>
                    </StackLayout>
                </Frame>
        </ContentPage>
    </TabbedPage.Children>



</TabbedPage>
<?xml version="1.0" encoding="UTF-8"?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    xmlns:view="clr-namespace:TesteDrive.Views"
    x:Class="TesteDrive.Views.MasterDetailView">

    <MasterDetailPage.Detail>
        <NavigationPage>
            <x:Arguments>
                <view:ListagemView></view:ListagemView>
            </x:Arguments>
        </NavigationPage>
    </MasterDetailPage.Detail>

</MasterDetailPage>
1 resposta
solução!

Olá, Alexander

Aparentemente o problema é nesta linha:

<Button Text="SALVAR" Command="SalvarPerfilCommand"></Button>

Faltou colocar as chaves e o Binding:

<Button Text="SALVAR" Command="{Binding SalvarPerfilCommand}"></Button>

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