In my mobile application I have a part that I retrieve the local date and time, so the date is bringing the month first, then the day and last year, how to change it, here is my code:
In my layout file:
<Label Text="Data" FontAttributes="Bold"/>
<Label Text="{Binding DataAtual}"/>
Here is the class created for the logical part:
public class DataHora : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private DateTime _dataAtual;
public DateTime DataAtual
{
set
{
if (_dataAtual == value)
return;
_dataAtual = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DataAtual)));
}
get
{
return _dataAtual;
}
}
public DataHora()
{
DataAtual = DateTime.Now;
Device.StartTimer(TimeSpan.FromSeconds(1), () =>
{
DataAtual = DateTime.Now;
return true;
});
}
}
And here in my mainpage file:
BindingContext = new DataHora();