Exemple #1
0
        private object GetData()
        {
            if (Type == null)
                return null;

            switch ((BindingType)Type.Value)
            {
                case BindingType.ObservableCollection:
                    {
                        return this.northwind.Customers;
                    }
                case BindingType.ICollectionView:
                    {
                        var cvs = new CollectionViewSource();
                        cvs.Source = this.northwind.Order_Details;
                        return cvs.View;
                    }
                case BindingType.DynamicData:
                    {
                        var data = new ObservableCollection<MyDataRow>();
                        for (int i = 0; i < 100; i++)
                        {
                            var row = new MyDataRow();

                            for (int j = 0; j < 10; j++)
                            {
                                row[string.Format("Column{0}", j)] = string.Format("Cell {0} {1}", i, j);
                            }

                            data.Add(row);
                        }

                        return data;
                    }
#if !SILVERLIGHT
                case BindingType.DataTable:
                    {
                        return GetDataTable();
                    }
#endif
                case BindingType.Xml:
                    {
                        return GetXmlData();
                    }
            }

            return null;
        }