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");
        }
Esempio n. 2
0
// <Snippet1>
    private void ClearAndAdd()
    {
        GridTableStylesCollection gts = dataGrid1.TableStyles;

        gts.Clear();
    }