WP7 silverlight toolkit 之 AutoCompleteBox 应用学习

阅读更多

案例一:

 

xaml:

                 HorizontalAlignment="Left"
                Margin="43,43,0,0"
                Name="autoCompleteBox1"
                VerticalAlignment="Top"
                Width="351"
                 IsTextCompletionEnabled="True"
                /> 

这个很简单,就是直接拖进来,多加了个IsTextCompletionEnabled属性,设置边输的时候是否匹配

cs:


            List list = new List();
            list.Add("aaaaaaa");
            list.Add("bbbbbbb");
            list.Add("ccccccc");
            list.Add("ddddddd");
            list.Add("eeeeeee");
            list.Add("fffffff");

            autoCompleteBox1.ItemsSource = list;

--------------------------------------------------------------------

案例二:xaml:

                HorizontalAlignment="Left"
                Margin="43,121,0,0"
                Name="autoCompleteBox2"
                VerticalAlignment="Top"
                Width="351"
                ValueMemberPath="Key"
                >
               
                   
                       
                                                      
                                                                              
                       

                       
                   
                   
               
                
           

这里就有两个显示的,要注意的就是ValueMemberPath,这个是设置输哪个值的时候进行匹配,因为有两个,你要设置一个

cs:

    Dictionary dict = new Dictionary();
            dict.Add("Monday", "/Image/1.jpg");
            dict.Add("Mm", "/Image/2.jpg");
            dict.Add("Mmmy", "/Image/3.jpg");
            dict.Add("Mommm", "/Image/1.jpg");          
            autoCompleteBox2.ItemsSource = dict;

---------------------------------------------------------------------

案例三:xaml:

                HorizontalAlignment="Left"
                Margin="43,302,0,0"
                Name="autoCompleteBox3"
                VerticalAlignment="Top"
                Width="372"
                ValueMemberPath="name"
                >
               
                   
                       
                           
                           
                       

                   

               

           

这个要注意的和上面的一样

cs:


            List Infoa = new List();
            Info i = new Info();
            i.name = "jacklai";
            i.sex = "男";
            Infoa.Add(i);
            Info i1 = new Info();
            i1.name = "MarryLai";
            i1.sex = "女";
            Infoa.Add(i1);
            autoCompleteBox3.ItemsSource = Infoa;

 

______________________________________________________

属性:
1.FilterMode:匹配方式
2.IsDropDownOpen:下拉列表是否打开
3.IsTextCompletionEnable:自动完成匹配填写
4.MaxDropDownHeight:下拉列表的最大高度
5.MinimumPopulateDelay:最小匹配时间
6.MinimumPrefixLength:最短匹配长度
事件:
DropDownClosed/DropDownCloseing
DropDownOpened/DropDownOpening

你可能感兴趣的:(AutoCompleteBox)