Why is only the second of two labels in a xaml page updating when I use a timer

Solution 1:

Please put your code in Device.BeginInvokeOnMainThread:

     public void calc(DateTime dt)
    {
        System.DateTime departure = new System.DateTime(2022, 2, 2, 22, 15, 0);

        TimeSpan timeSpan = departure.Subtract(dt);
        opt = String.Format("Days: {0:N0}", timeSpan.TotalDays);
        opt += String.Format("\nHours: {0:N0}", timeSpan.TotalHours);
        opt += String.Format("\nMinutes: {0:N0}", timeSpan.TotalMinutes);
        opt += String.Format("\nSeconds: {0:N0}", timeSpan.TotalSeconds);
        

        Device.BeginInvokeOnMainThread(() => {
            txtOutput.Text = opt;

            txtCountdown.Text = timeSpan.ToString(@"d\:hh\:mm\:ss");
        });
    }