xmal
<AutoSuggestBox.ItemTemplate> <DataTemplate x:DataType="local:ImageBrushAndFileInfo"> <StackPanel Orientation="Horizontal" > <TextBlock Text="{x:Bind file.DisplayName}" /> <ToolTipService.ToolTip> <ToolTip> <Grid ToolTipService.ToolTip="{x:Bind file.Path}"> <controls:ImageEx Width="100" gif:AnimationBehavior.RepeatBehavior="Forever" Source="{x:Bind bitmapImage}"> <ToolTipService.ToolTip> <ToolTip> <StackPanel> <TextBlock FontSize="16" Text="{x:Bind file.Name,Mode=OneWay}"></TextBlock> <TextBlock Text="{x:Bind file.DateCreated.UtcDateTime,Mode=OneWay}"></TextBlock> </StackPanel> </ToolTip> </ToolTipService.ToolTip> </controls:ImageEx> </Grid> </ToolTip> </ToolTipService.ToolTip> </StackPanel> </DataTemplate> </AutoSuggestBox.ItemTemplate>
code behind
private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) { var sList = new List<ImageBrushAndFileInfo>(); foreach (var group in ImageGroups) { foreach (var ImgInfo in group.ImageObjects) { if (ImgInfo.file.Name.Contains(sender.Text)) { sList.Add(ImgInfo); Debug.WriteLine(ImgInfo.file.Name); } } } sender.ItemsSource = sList; }效果
处理提交
private void Search_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { var imgInfo = args.ChosenSuggestion as ImageBrushAndFileInfo; sender.Text = imgInfo.file.DisplayName; Frame.Navigate(typeof(ImagePage),imgInfo); }