TAILIEUCHUNG - Apress pro Silverlight 3 in C# phần 4

Silverlight hỗ trợ phân phối video chất lượng cao một cách nhanh chóng và hiệu quả đến tất cả các trình duyệt web lớn chạy trên nền Mac OS hoặc Windows. | CHAPTER 5 ELEMENTS You then decide to build an AutoCompleteBox that attempts to match the user s text with a Product object. In preparation for this step you fill the collection with product objects Product products new new ProdUct Peanut Butter Applicator C_PBA-01 new Product Pelvic Strengthened C_PVS-309 . products If you take no further steps the AutoCompleteBox will use its standard behavior. As the user types it will call ToStringO on each Product object. It will then use that text to perform its suggestion filtering. Because the Product class overrides the ToString method to return the product name the AutoCompleteBox will attempt to match the user s text with a product name which is perfectly reasonable. However if you perform custom filtering you can get a bit more sophisticated. For example you can check if the user s text matches the ProductName property or the ProductCode property and deem the Product object as a match either way. Here s an example of the custom filtering logic that does the trick public bool ProductItemFilter string text object item Product product Product item Call it a match if the typed-in text appears in the product code or at the beginning of the product name. return text text You simply need to connect this method to your AutoComplexBox when it s first initialized ProductItemFilter Now if the user types the text PBA it matches the product code C_PBA-01 and see the matching item Peanut Butter Applicator in the list of suggestions as shown in Figure 5-15. 172 CHAPTER 5 ELEMENTS Figure 5-15. A custom search that matches product codes Dynamic Item Lists So far you ve used the ItemsSource property to fill the AutoCompleteBox with a collection of suggestions. For this to work you must have the complete list and it must be a manageable size. If you need to pull the information from somewhere else or the list

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.