Exemplo n.º 1
0
        public void AddRangeTest()
        {
            var collection = new ResettableObservableCollection <Item>();

            var invokeCount = 0;

            Item[] items = { new Item(), new Item(), };
            NotifyCollectionChangedEventHandler handler = (object sender, NotifyCollectionChangedEventArgs e) =>
            {
                ++invokeCount;
                Assert.IsTrue(e.Action == NotifyCollectionChangedAction.Add);
                Assert.IsTrue(e.OldItems == null);
                Assert.IsTrue(e.NewItems != null);
                Assert.IsTrue(e.OldStartingIndex == -1);
                Assert.IsTrue(e.NewStartingIndex == 0);
                Assert.IsTrue(e.NewItems.Count == items.Length);
                Assert.IsTrue(e.NewItems.Cast <Item>().SequenceEqual(items));
            };

            collection.CollectionChanged += handler;

            collection.AddRange(items);

            collection.CollectionChanged -= handler;

            Assert.IsTrue(invokeCount == 1);
        }
Exemplo n.º 2
0
        public override void Initialise(ItemsControl todoList,
                                        ResettableObservableCollection <ShoppingItemViewModel> todoItems)
        {
            base.Initialise(todoList, todoItems);

            SetFrameReporting();
        }
Exemplo n.º 3
0
        public virtual void Initialise(ItemsControl todoList, ResettableObservableCollection<ToDoItemViewModel> todoItems)
        {
            _todoList = todoList;
              _todoItems = todoItems;

              // when the ItemsControl has been rendered, we can locate the ScrollViewer
              // that is within its template.
              _todoList.InvokeOnNextLayoutUpdated(() => LocateScrollViewer());

              IsEnabled = true;
        }
Exemplo n.º 4
0
        public virtual void Initialise(ItemsControl todoList, ResettableObservableCollection <ToDoItemViewModel> todoItems)
        {
            _todoList  = todoList;
            _todoItems = todoItems;

            // when the ItemsControl has been rendered, we can locate the ScrollViewer
            // that is within its template.
            _todoList.InvokeOnNextLayoutUpdated(() => LocateScrollViewer());

            IsEnabled = true;
        }
Exemplo n.º 5
0
        public void ClearTest()
        {
            var collection = new ResettableObservableCollection <Item>();

            var invokeCount = 0;

            Item[] items = { new Item(), new Item(), };
            collection.AddRange(items);
            NotifyCollectionChangedEventHandler handler = (object sender, NotifyCollectionChangedEventArgs e) =>
            {
                ++invokeCount;
                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Remove:
                    Assert.IsTrue(invokeCount == 1);
                    Assert.IsTrue(e.OldItems != null);
                    Assert.IsTrue(e.NewItems == null);
                    Assert.IsTrue(e.OldStartingIndex == 0);
                    Assert.IsTrue(e.NewStartingIndex == -1);
                    Assert.IsTrue(e.OldItems.Count == items.Length);
                    Assert.IsTrue(e.OldItems.Cast <Item>().SequenceEqual(items));
                    break;

                case NotifyCollectionChangedAction.Reset:
                    Assert.IsTrue(invokeCount == 2);
                    Assert.IsTrue(e.OldItems == null);
                    Assert.IsTrue(e.NewItems == null);
                    Assert.IsTrue(e.OldStartingIndex == -1);
                    Assert.IsTrue(e.NewStartingIndex == -1);
                    break;

                default:
                    Assert.Fail();
                    break;
                }
            };

            collection.CollectionChanged += handler;

            collection.Clear();

            collection.CollectionChanged -= handler;

            Assert.IsTrue(invokeCount == 2);
        }
Exemplo n.º 6
0
        public override void Initialise(ItemsControl todoList, ResettableObservableCollection <ToDoItemViewModel> todoItems)
        {
            base.Initialise(todoList, todoItems);

            Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);
        }
Exemplo n.º 7
0
        public override void Initialise(ItemsControl todoList, ResettableObservableCollection <ToDoItemViewModel> todoItems)
        {
            base.Initialise(todoList, todoItems);

            todoList.KeyUp += ItemsControl_KeyUp;
        }
        public override void Initialise(ItemsControl todoList, ResettableObservableCollection<ToDoItemViewModel> todoItems)
        {
            base.Initialise(todoList, todoItems);

            Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);
        }