Hello,
I am using the XLabs library for forms and all look good. But I have a simple question.
If I have a simple binding from a string in the view model to a label and I set the view model string var to a text all looks good.
BUT if I set the view model var in a function that is called by a command from the XAML the binding did NOT work !!!???
XAML:
<Label Text="{Binding Data}"></Label>
ViewModel class:
using XLabs.Forms.Mvvm;
public class DataViewModel : ViewModel
{
.....
Property:
private string data;
public string Data
{
get
{
return data;
}
set
{
data = value;
SetProperty(ref data, value);
}
}
.....
Constructor:
public DataViewModel ()
{
// this WORKS !!!
this.Data = "Hello";
}
With command (the command itself successfully calls the update method):
private Command getDataCommand;
public Command GetDataCommand
{
get
{
return getDataCommand ?? (getDataCommand = new Command(async () => await GetData(),
() => true));
}
}
...
private async Task GetData()
{
// does NOT work !!!!!
this.Data = "Hello";
}
The IoC of XLabs are set, also the ViewFactory stuff:
ViewFactory.Register< DataViewModelPage, DataViewModel > ();
DataViewModelPage dataViewModelPage = (DataViewModelPage)ViewFactory.CreatePage< DataViewModel, DataViewModelPage> ();
Any idea why the binding works when the data is set inside the constructor, BUT NOT from a command ?
Thanx
Marco