首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > CAD教程 >

WP7 silverlight toolkit 之 AutoCompleteBox 使用学习

2012-06-27 
WP7 silverlight toolkit 之 AutoCompleteBox 应用学习案例一:?xaml:?toolkit:AutoCompleteBox ?????????

WP7 silverlight toolkit 之 AutoCompleteBox 应用学习

案例一:

?

xaml:

?<toolkit:AutoCompleteBox
??????????????? HorizontalAlignment="Left"
??????????????? Margin="43,43,0,0"
??????????????? Name="autoCompleteBox1"
??????????????? VerticalAlignment="Top"
??????????????? Width="351"
???????????????? IsTextCompletionEnabled="True"
??????????????? />?

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

cs:


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

??????????? autoCompleteBox1.ItemsSource = list;

<!--StartFragment -->

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

案例二:xaml:

<toolkit:AutoCompleteBox
??????????????? HorizontalAlignment="Left"
??????????????? Margin="43,121,0,0"
??????????????? Name="autoCompleteBox2"
??????????????? VerticalAlignment="Top"
??????????????? Width="351"
??????????????? ValueMemberPath="Key"
??????????????? >
??????????????? <toolkit:AutoCompleteBox.ItemTemplate>
??????????????????? <DataTemplate>
??????????????????????? <StackPanel Orientation="Horizontal">
??????????????????????????? <Image Source="{Binding Value}" Width="100" Height="100"></Image>??????????????????????????
??????????????????????????????? <TextBlock Text="{Binding Key}" Margin="0,50"></TextBlock>??????????????????????????????????????????????
??????????????????????? </StackPanel>
???????????????????????
??????????????????? </DataTemplate>???????????????????
??????????????? </toolkit:AutoCompleteBox.ItemTemplate>????????????????
??????????? </toolkit:AutoCompleteBox>

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

cs:

??? Dictionary<string, string> dict = new Dictionary<string, string>();
??????????? 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:

<toolkit:AutoCompleteBox
??????????????? HorizontalAlignment="Left"
??????????????? Margin="43,302,0,0"
??????????????? Name="autoCompleteBox3"
??????????????? VerticalAlignment="Top"
??????????????? Width="372"
??????????????? ValueMemberPath="name"
??????????????? >
??????????????? <toolkit:AutoCompleteBox.ItemTemplate>
??????????????????? <DataTemplate>
??????????????????????? <StackPanel>
??????????????????????????? <TextBlock Text="{Binding name}"></TextBlock>
??????????????????????????? <TextBlock Text="{Binding sex}" Foreground="Gray"></TextBlock>
??????????????????????? </StackPanel>
??????????????????? </DataTemplate>
??????????????? </toolkit:AutoCompleteBox.ItemTemplate>
??????????? </toolkit:AutoCompleteBox>

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

cs:


??????????? List<Info> Infoa = new List<Info>();
??????????? 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

热点排行