Xamarin Forms - How to make Datime.Now dynamic?

Asked

Viewed 101 times

1

How to make the Datime.Now. dynamic on Xamarin Forms ? I need time to keep running. In this case it’s stopped.

I have a Label that captures the data of a class

Label Text="{Binding data}" TextColor="Blue" >HorizontalOptions="CenterAndExpand"/>

public static Tempo getTempo()
{
            var tempo = new Tempo() { data = DateTime.Now };
            return tempo;
}

at the end I urge

 public EstiloDinamico()
 {
      InitializeComponent();
      var tempo = tempoViewModel.getTempo();
      tvm = new tempoViewModel(tempo);
      BindingContext = tvm;
}

1 answer

0

You need to give a setProperty to inform the view that you have had a change in the variable implements the class : Bindablebase and an example of what your variable would look like

private string _title;
public string Title
{
    get { return _title; }
    set { SetProperty(ref _title, value); }
}

whenever there is a change inside the variable it will signal to the view and will be changed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.