Example #1
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);
            }
        }