0
第一次工作的Silverlight,想與圖像拇指和圖片標題綁定AutoCompleteBox(通過Web服務),將通過圖像標題搜索,我能夠做綁定圖片標題AutoCompleteBox結合到Web服務
工作過程
Web服務
[WebMethod] public List<imagedata> Searchimage(string s) { var db = new PetaPoco.Database("sales"); var list = from search in db.Query<imagedata>("select * from imagedata").ToList() where search.imgname.Contains(s) select search; return list.ToList<imagedata>() ; }
XAML
名<sdk:AutoCompleteBox x:Name="searchText" Populating="searchText_Populating" /> </StackPanel>
的.cs
private void searchText_Populating(object sender, PopulatingEventArgs e) { mySoapClient proxy = new mySoapClient(); proxy.SearchimageCompleted += new EventHandler<SearchimageCompletedEventArgs>(proxy_ImageGetCompleted); proxy.SearchimageAsync(searchText.Text); } void proxy_ImageGetCompleted(object sender, SearchimageCompletedEventArgs e) { var searchResults = new List<imagedata>(e.Result); var data = new List<string>(); foreach (var x in searchResults) { data.Add(x.imgname); } searchText.ItemsSource = data; searchText.PopulateComplete(); }
想爲圖像拇指和圖像都標題圖片的網址綁定,我申請以下過程
<sdk:AutoCompleteBox x:Name="searchText" Populating="searchText_Populating">
<sdk:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image x:Name="image1" Height="100" Width="100" Canvas.Left="0" Canvas.Top="0"></Image>
<TextBlock VerticalAlignment="Center" Margin="10 0 0 0" />
</StackPanel>
</DataTemplate>
</sdk:AutoCompleteBox.ItemTemplate>
我怎麼能收集綁定到DataTemplate中的autocompletebox,我可以使用字典嗎?如果是,那麼我如何將它綁定到數據模板