the issue appears when trying to bind the properties of the view to any source created on ViewModel, an example is the label's Text property<-binding->test(below on code) not works, but Text property of Button i make a bind to another object sended to this viewModel and work's normally. I just would like to understand why the Binding is not working as usual. Here's the code.
XAML.cs
public PopupView(Func<bool> metodo, Tarefa tarefa)
{
BindingContext = new ViewModels.Popups.PopupViewModel(metodo, tarefa);
InitializeComponent();
}
XAML
<pages:PopupPage
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Taskinho.Views.Popups.PopupView"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup">
<StackLayout>
<Label HorizontalOptions="Center" Text="{Binding test}" />
<Button Text="{Binding tarefa.TarefaTitulo}" Command="{Binding Confirmar}" />
</StackLayout>
</pages:PopupPage>
ViewModel
//Property
private Tarefa _Tarefa;
public Tarefa tarefa
{
get { return _Tarefa; }
set { _Tarefa = value;
NotifyPropertyChanged("Tarefa");
}
}
//another property
public string test = "Test Name";
//Constructor
public PopupViewModel(Func<bool> metodoParam, Tarefa TarefaParam)
{
this.tarefa = new Tarefa();
ExecutarCommand = new Command(ExecutarAction);
}
//The binded Command(Not finded by the binding)
public Command ExecutarCommand
{
get;
set;
}
//Action of Command
void ExecutarAction()
{
//do something
}
I tried to use Path="" and Source="" on Button binding but i don't know how to use for this situation.
Project Link Open/Public on Git
Thank's