PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Visual Studio 2008/CSWPFPaging/ReadMe.txt

#
Plain Text | 55 lines | 33 code | 22 blank | 0 comment | 0 complexity | 005d6fd9ffa15fe503651e895c1a526f MD5 | raw file
 1================================================================================
 2       WPF APPLICATION : CSWPFPaging Project Overview
 3       
 4                       WPF Paging Sample
 5                        
 6===============================================================================
 7
 8/////////////////////////////////////////////////////////////////////////////
 9Use:
10
11The sample demonstrates how to page data in WPF.
12   
13
14/////////////////////////////////////////////////////////////////////////////
15Code Logic:
16
17
181. Create a Customer class with properties of ID, Name, Age, Country, etc.
19
202. Define a ListView with columns binding to each properties of the Customer object;
21
223. Drag 4 buttons on to the MainWindow, which are for displaying first, previous,
23   next, last page.
24 
254. Construct an ObservableCollection collection of Customer objects. 
26
275. Create a CollectionViewSource object and set source to the customer list.
28
296. Handle the CollectionViewSource.Filter event to show data only in the current page.
30
31        void view_Filter(object sender, FilterEventArgs e)
32        {
33            int index = customers.IndexOf((Customer)e.Item);
34
35            if (index >= itemPerPage * currentPageIndex && index < 
36                itemPerPage * (currentPageIndex + 1))
37            {
38                e.Accepted = true;
39            }
40            else
41            {
42                e.Accepted = false;
43            }
44        }
45        
467. Binding the CollectionViewSource object to the ListView.
47
48
49
50/////////////////////////////////////////////////////////////////////////////
51References:
52
53   
54
55/////////////////////////////////////////////////////////////////////////////