示例#1
0
        public EntityDemoViewModel()
        {
            DOCS = new DataObjectCollectionSource();

            DB = new CharacterDatabase();

            DOCS.ItemsSource = DB.Characters;

            LoadDataCommand = new DelegateCommandSync(() => LoadData());
        }
示例#2
0
        public PagedListDemoViewModel()
        {
            //SampleDataSource dataSource = new SampleDataSource();
            //m_Vector = new VirtualizingDataList<string>(dataSource);

            Vector = new PagedList <Data>();

            for (int i = 0; i < 16; i++)
            {
                Vector.Add(new Data(string.Format("{0}", i)));
            }
            //dataSource.items.Add(string.Format("Base Item: {0}", i));

            AddNewItemsCommand = new DelegateCommand(() =>
            {
                int count = 10;    // rnd.Next(5, 20);
                for (int i = 0; i < count; i++)
                {
                    //dataSource.items.Add(string.Format("{1} {0}", i, DateTime.Now.TimeOfDay));
                    Vector.Add(new Data(string.Format("{1} {0}", i, DateTime.Now.TimeOfDay)));
                }
            });

            RemoveSelectedCommand = new DelegateCommand(() =>
            {
                Vector.Remove((Data)SelectedItem);
            });

            AddOneItemCommand = new DelegateCommandSync(() =>
            {
                //dataSource.items.Add("oneItem");
                Vector.Add(new Data("oneItem"));
            });

            InsertBeforeCommand = new DelegateCommand((o) =>
            {
                Data so   = (Data)o;
                int index = Vector.IndexOf(so);
                Vector.Insert(index, new Data("B-I"));
            }, (o) =>
            {
                return(o != null);
            });
            InsertAfterCommand = new DelegateCommand((o) =>
            {
                for (int i = 0; i < 5; i++)
                {
                    Data so   = (Data)o;
                    int index = Vector.IndexOf(so);
                    index++;
                    Vector.Insert(index, new Data("A-I"));
                }
            }, (o) =>
            {
                return(o != null);
            });
            InsertItemsBeforeCommand = new DelegateCommand((o) =>
            {
                for (int i = 0; i < 5; i++)
                {
                    Data so   = (Data)o;
                    int index = Vector.IndexOf(so);
                    Vector.Insert(index, new Data("B-I"));
                }
            }, (o) =>
            {
                return(o != null);
            });
            InsertItemsAfterCommand = new DelegateCommand((o) =>
            {
                Data so   = (Data)o;
                int index = Vector.IndexOf(so);
                index++;
                Vector.Insert(index, new Data("A-I"));
            }, (o) =>
            {
                return(o != null);
            });
            UpdateItemCommand = new DelegateCommand((o) =>
            {
                int oi     = Vector.IndexOf((Data)o);
                Vector[oi] = new Data(Convert.ToString(DateTime.Now.Ticks));
            }, (o) => o != null);
        }