Exemplo n.º 1
0
        private void GetDataHandler(object sender, RoutedEventArgs e)
        {
            customerProvider = new DemoCustomerProvider(1000 /*number of items*/, 2000 /*delay*/);
            AsyncVirtualizingCollection <Customer> customerList = new AsyncVirtualizingCollection <Customer>(customerProvider, 30 /*page size*/, 3000 /*timeout*/);

            this.DataContext = customerList;
        }
Exemplo n.º 2
0
        void refreshButton_Click(object sender, RoutedEventArgs e)
        {
            // create the demo items provider according to specified parameters
            int numItems   = int.Parse(tbNumItems.Text);
            int fetchDelay = int.Parse(tbFetchDelay.Text);
            DemoCustomerProvider customerProvider = new DemoCustomerProvider(numItems, fetchDelay);

            // create the collection according to specified parameters
            int pageSize    = int.Parse(tbPageSize.Text);
            int pageTimeout = int.Parse(tbPageTimeout.Text);

            // ListView.ItemsSource プロパティに設定
            if (rbNormal.IsChecked.Value)
            {
                // 同期する
                DataContext = new List <Customer>(
                    customerProvider.GetRange(0, customerProvider.Count().Result).Result);
            }
            else if (rbVirtualizing.IsChecked.Value)
            {
                DataContext = new VirtualizingCollection <Customer>(customerProvider, pageSize);
            }
            else if (rbAsync.IsChecked.Value)
            {
                DataContext = new AsyncVirtualizingCollection <Customer>(customerProvider, pageSize);
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // create the demo items provider according to specified parameters
            int numItems         = int.Parse(tbNumItems.Text);
            int fetchDelay       = int.Parse(tbFetchDelay.Text);
            var customerProvider = new DemoCustomerProvider(numItems, fetchDelay);

            // create the collection according to specified parameters
            int pageSize    = int.Parse(tbPageSize.Text);
            int pageTimeout = int.Parse(tbPageTimeout.Text);

            if (rbNormal.IsChecked.Value)
            {
                DataContext = new List <Customer>(customerProvider.FetchRange(0, customerProvider.FetchCount()));
            }
            else if (rbVirtualizing.IsChecked.Value)
            {
                DataContext = new VirtualizingCollection <Customer>(customerProvider, pageSize);
            }
            else if (rbAsync.IsChecked.Value)
            {
                DataContext = new AsyncVirtualizingCollection <Customer>(customerProvider, pageSize, pageTimeout * 1000);
            }
        }