Exemple #1
0
        public HistoryViewModel(HistoryService historyService)
        {
            _historyService = historyService;

            // Commands
            ClearHistoryCommand = new RelayCommand(() =>
            {
                _historyService.ClearHistory();
                PopulateHistory();
            });

            // Initial population
            PopulateHistory();

            // Events
            Localization.PropertyChanged         += (sender, args) => PopulateHistory();
            _historyService.HistoryEntryRecorded += (sender, args) =>
            {
                DispatcherHelper.UIDispatcher.InvokeSafe(
                    () => History.Insert(0, new HistoryViewEntry(args.Entry.Date, Localization.Localize(args.Entry))));
            };
        }