private void _dictionaryTestButton_Click(object sender, EventArgs e)
        {
            var dictionary = new ObservableDictionary <string, int>();

            dictionary.ObservationWindow.ItemAdded += (dict, value, key) =>
                                                      _outputWriter.WriteLine("Single event: Added {0} at {1} ", value, key);

            dictionary.ObservationWindow.ItemRemoved += (dict, value, key) =>
                                                        _outputWriter.WriteLine("Single event: Removed {0} at {1} ", value, key);

            dictionary.ObservationWindow.Changed += (dict, events) => {
                _outputWriter.WriteLine("Global Handler");
                foreach (var @event in events)
                {
                    _outputWriter.WriteLine("\t: {0} {1} at {2} ", @event.EventType, @event.Item, @event.Location);
                }
            };

            dictionary.Add("string 1", 1);
            dictionary.Remove("string 1");
            dictionary.Add("string 2", 2);
            dictionary.Add("string 3", 3);
            dictionary.Add("string 4", 4);
            dictionary.Add("string 5", 5);
            dictionary.Add("string 6", 6);
            dictionary["string 6"] = -6;
            dictionary.Remove("string 1");
            dictionary.Remove(dictionary.ElementAt(0));
            dictionary.Clear();
        }
示例#2
0
        private void ViewNote(object sender, RoutedEventArgs e)
        {
            var  title    = sender as ListBox;
            var  noteDict = title.SelectedItem as Dictionary <string, int>;
            var  tuple    = titleDict.ElementAt(title.SelectedIndex);
            int  noteId   = tuple.Value;
            Note note     = repo.GetNoteById(noteId);
            var  v        = new ViewNote(note);

            v.Show();
        }