0
votes

I have created a list of stores added it to a picker but from the views it is not loading. It is showing a picker with no items.

ViewModel code as follows

public List<string> Stores = new List<string>
        {
            "store 1",
            "store 2",
            "store 3"
        };

private int _selectedStoreIndex = -1;
        public int SelectedStoreIndex
        {
            get { return _selectedStoreIndex; }
            set
            {
                if (_selectedStoreIndex != value)
                {
                    _selectedStoreIndex = value;

                    UpdateStoreSelection();
                    OnPropertyChanged();
                }
            }
        }

Xaml file

<Picker ItemsSource="{Binding Stores}" SelectedIndex="{Binding SelectedStoreIndex}"/>
2
Hi, you could have a look at Lifecycle methods to add timer inside OnStart/OnSleep/OnResume to calculate the running time. - Junior Jiang

2 Answers

0
votes

When a cold start is made OnStart method in App.xaml.cs is called. You can then use Secure Storage / Preference to save a key in local storage in each platform and then just use DateTime.Now to just calculate the difference. And when the app is destroyed and restarted , OnStart will be called again and just reset the key.

0
votes

You just need get the start time of the process,and the current time.

var startime = Process.GetCurrentProcess().StartTime;
var currenttime = DateTime.Now;
var runningtime = (nowtime - startime).TotalSeconds;