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 TestIndexContains() { 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(); IList ilist = (IList)sc; Assert.AreEqual(1, ilist.IndexOf(ts2), "A1"); Assert.AreEqual(false, sc.Contains("nothing"), "A2"); Assert.AreEqual(true, sc.Contains(ts3), "A3"); }