我需要根据在 windows phone 7 文本框中输入的文本突出显示搜索结果,
通常的 wpf 代码在 windows phone 7 中不起作用。有人说如何在 windows phone 7 中实现这一点
实际上这是我用来填充联系人列表的 xaml 列表框,
<ListBox Name="ContactList" ItemsSource="{Binding}" Margin="14,85,14,28" Foreground="White" SizeChanged="ContactList_SizeChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Border BorderThickness="2" HorizontalAlignment="Left" VerticalAlignment="Center" BorderBrush="{StaticResource PhoneAccentBrush}" >
<Image Source="{Binding Converter={StaticResource ContactPictureConverter}}" Width="48" Height="48" Stretch="Fill" Name="img1" />
</Border>
<TextBlock Name="ContactResults" Text="{Binding Path=DisplayName, Mode=OneWay}" FontSize="{StaticResource PhoneFontSizeExtraLarge}" Margin="18,8,0,0" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBox Name="contactFilterString" Margin="0,0,0,528" TextChanged="contactFilterString_TextChanged" />
C#代码,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
//using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.UserData;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.ObjectModel;
using Microsoft.Phone.Shell;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Text.RegularExpressions;
namespace SmartContactsApp
{
public partial class MainPage : PhoneApplicationPage
{
private List<Address> lstAddress = new List<Address>();
public string addressJson = string.Empty;
// Constructor
public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
CreateSecondaryTile();
}
/// <summary>
/// To List all the Contacts. . .
/// </summary>
private void ContactListing()
{
ContactList.DataContext = null;
Contacts cons = new Contacts();
cons.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(Contacts_SearchCompleted);
cons.SearchAsync(contactFilterString.Text, FilterKind.DisplayName, "Contacts");
}
/// <summary>
/// To Fetch All Contacts from Mobile Contacts. . .
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
{
try
{
ContactList.DataContext = e.Results;
}
catch (Exception)
{
throw;
}
}
private void contactFilterString_TextChanged(object sender, TextChangedEventArgs e)
{
ContactListing();
}
}
如何在此突出显示,
提前致谢!