public GridTableStylesCollectionTests()
        {
            DataGrid grid = new DataGrid();
            GridTableStylesCollection sc = grid.TableStyles;

            sc.CollectionChanged += new CollectionChangeEventHandler(OnCollectionChanged);

            Console.WriteLine("GridColumnStylesCollection default --- ");
            DumpGridTableStylesCollection(sc);

            Console.WriteLine("Add single item");
            DataGridTableStyle ts = new DataGridTableStyle();

            ts.MappingName = "Table1";
            sc.Add(ts);

            Console.WriteLine("Add multipleitems");
            sc.AddRange(new DataGridTableStyle [] { new DataGridTableStyle(), new DataGridTableStyle() });
            Console.WriteLine("Remove At");
            sc.RemoveAt(2);

            Console.WriteLine("Add single item");
            ts             = new DataGridTableStyle();
            ts.MappingName = "Table2";
            sc.Add(ts);

            for (int i = 0; i < sc.Count; i++)
            {
                Console.WriteLine("Element {0}:{1}", i, sc[i].MappingName);
            }

            sc.Remove(ts);
            Console.WriteLine("Contains Table1 {0}", sc.Contains("Table1"));
            Console.WriteLine("Contains Table4 {0}", sc.Contains("Table4"));
        }
        public void TestRemove()
        {
            DataGrid grid = new DataGrid();
            GridTableStylesCollection sc = grid.TableStyles;

            sc.CollectionChanged += new CollectionChangeEventHandler(OnCollectionEventHandler);

            // Add single
            DataGridTableStyle ts1 = new DataGridTableStyle();

            ts1.MappingName = "Table1";
            sc.Add(ts1);

            DataGridTableStyle ts2 = new DataGridTableStyle();

            ts2.MappingName = "Table2";
            sc.Add(ts2);

            DataGridTableStyle ts3 = new DataGridTableStyle();

            ts3.MappingName = "Table3";
            sc.Add(ts3);

            ResetEventData();
            sc.Remove(ts2);
            Assert.AreEqual(true, eventhandled, "A1");
            Assert.AreEqual(ts2, Element, "A2");
            Assert.AreEqual(CollectionChangeAction.Remove, Action, "A3");
            Assert.AreEqual(2, sc.Count, "A4");

            ResetEventData();
            sc.RemoveAt(0);
            Assert.AreEqual(true, eventhandled, "A5");
            Assert.AreEqual(ts1, Element, "A6");
            Assert.AreEqual(CollectionChangeAction.Remove, Action, "A7");
            Assert.AreEqual(1, sc.Count, "A8");

            ResetEventData();
            sc.Clear();
            Assert.AreEqual(null, Element, "A9");
            Assert.AreEqual(CollectionChangeAction.Refresh, Action, "A10");
        }