<TextBox x:Name="tbSeach" Height="25" Width="60" HorizontalAlignment="Center" VerticalAlignment="Top"  TextChanged="tbSeach_TextChanged"/>

  

               private void tbSeach_TextChanged(object sender, TextChangedEventArgs e)
{
_seachfooList
= new List<FooViewModel>();
foreach (FooViewModel model in treeGoods.Items)
{
foreach (FooViewModel foo in findNode(model, tbSeach.Text.Trim()))
{
foo.IsChecked
= true;
};
}
}

  

        //模糊查询算法
private List<FooViewModel> findNode(FooViewModel tnParent, string strValue)
{
if (tnParent == null) return null;
if (tnParent.Name.IndexOf(strValue) > -1 && !string.IsNullOrEmpty(strValue))
{
_seachfooList.Add(tnParent);
}
foreach (FooViewModel foo in tnParent.Children)
{
foo.IsChecked
= false;
findNode(foo, strValue);
}
return _seachfooList;
}

  

作者: .net菜菜 发表于 2011-07-21 15:23 原文链接

推荐.NET配套的通用数据层ORM框架:CYQ.Data 通用数据层框架
新浪微博粉丝精灵,刷粉丝、刷评论、刷转发、企业商家微博营销必备工具"