Silverlight telerik Control Learning: radcombobox AutoComplete)

Source: Internet
Author: User

Direct:

XAML SectionCode:

<Usercontrol xmlns: telerik = "http://schemas.telerik.com/2008/xaml/presentation" X: class = "telerik. sample. autoComplete "xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation "xmlns: x =" http://schemas.microsoft.com/winfx/2006/xaml "xmlns: D =" http://schemas.microsoft.com/expression/blend/2008 "xmlns: MC =" http://schemas.openxmlformats.org/markup-compatibility/2006 "xmlns: Common =" CLR-namespace: Co Mmon. silverlight; Assembly = Common. silverlight "xmlns: BO =" CLR-namespace: businessobject; Assembly = businessobject "MC: ignorable =" D "D: designheight =" 300 "D: designwidth = "400"> <grid X: Name = "layoutroot" background = "white"> <grid. resources> <common: objectcollection X: Key = "objcollection"> <BO: nodeitem text = "Shanghai" value = "sh" Description = "Shanghai is a bustling city"> </Bo: nodeitem> <BO: nodeitem text = "Shenzhen" value = "SZ" Description = "SAR of China"> </Bo: nodeitem> <Bo: nodeitem text = "Guangzhou" value = "GZ" Description = "Cantonese likes wontang"> </BO: nodeitem> <Bo: nodeitem text = "Beijing" value = "BJ" Description = "Beijing is the capital of China"> </Bo: nodeitem> </common: objectcollection> <! -- Data item template --> <datatemplate X: Key = "cboitemtemplate"> <grid. columndefinitions> <columndefinition> </grid. columndefinitions> <textblock text = "{binding value}" grid. column = "0" textalignment = "Left"> </textblock> <textblock text = "{binding text}" grid. column = "1" textalignment = "right"> </textblock> </GRID> </datatemplate> <! -- The selected template (which is invalid when iseditable = true) --> <datatemplate X: key = "cboselectionboxtemplate"> <stackpanel orientation = "horizontal"> <textblock text = "{binding text}" foreground = "red"/> <textblock margin = "3,0, 3, 0 ">/</textblock> <textblock text =" {binding value} "> </textblock> </stackpanel> </datatemplate> </grid. resources> <stackpanel horizontalalignment = "center" verticalalignment = "center"> <textblock> selectedvalue: </Textblock> <telerik: radmaskedtextbox maskedtext = "{binding elementname = radcombobox1, Path = selectedvalue, mode = twoway}" masktype = "NONE" isreadonly = "true"> </telerik: radmaskedtextbox> <textblock margin = ","> selecteditem. value: </textblock> <telerik: radmaskedtextbox maskedtext = "{binding elementname = radcombobox1, Path = selecteditem. value, mode = twoway} "masktype =" NONE "isreadonly =" true "> </telerik: RA Dmaskedtextbox> <textblock margin = ","> selecteditem. description: </textblock> <telerik: radmaskedtextbox maskedtext = "{binding elementname = radcombobox1, Path = selecteditem. description, mode = twoway} "masktype =" NONE "isreadonly =" true "> </telerik: radmaskedtextbox> <textblock margin =", "> selecteditem. text: </textblock> <telerik: radmaskedtextbox maskedtext = "{binding elementname = radcombobox1, path = Selecteditem. Text, mode = twoway} "masktype =" NONE "isreadonly =" true "> </telerik: radmaskedtextbox> <! -- Description --> <! -- Textsearchmode = "contains" indicates that, when a text search contains a keyword, it is considered to be a match --> <! -- Telerik: textsearch. textpath = "value" indicates that the search only matches the value attribute. --> <! -- Iseditable = "true" allows editing --> <! -- Isfilteringenabled = "true": when matching is searched, record items are automatically filtered --> <! -- Automatically expand when opendropdownonfocus = "true" gets the focus --> <! -- Itemtemplate = "{staticresource cboitemtemplate}" data item template --> <! -- Itemssource = "{staticresource objcollection}" data source --> <! -- Selectedvaluepath = "text" the object field corresponding to the selected value --> <! -- Emptytext = "select city" default text displayed when no selection is available --> <! -- Clearselectionbuttoncontent = "clear and select" clear the text of the selection button --> <! -- Clearselectionbuttonvisibility = "visible" display the clear selection button --> <telerik: radcombobox margin = "," X: name = "radcombox1" width = "180" textsearchmode = "contains" telerik: textsearch. textpath = "value" iseditable = "false" isfilteringenabled = "false" opendropdownonfocus = "true" itemtemplate = "{staticresource cboitemtemplate}" itemssource = "{staticresource objcollection}" selectedvaluepath = "Text "clearselectionbuttoncontent =" clear selection "clearselectionbuttonvisibility =" visible "emptytext =" select a city (enter the pinyin abbreviation) "selectionboxtemplate =" {staticresource cboselectionboxtemplate} "/> </stackpanel> </GRID> </usercontrol>

Background code: the advantages of binding are once again reflected by wood products :)

In my opinion, radcombobox has a small defect: when it is set to editable mode (iseditable = "true"), the selected template (selectionboxtemplate) will expire (there is a solution similar to hack: rewrite tostring () method and output desired results)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.