问题描述
在做一个Filter用C#的转过来view.Filter+=Me.FilterPredicate'这里出错view.Filter-=Me.FilterPredicate'这里出错'--------------------c#ICollectionViewview=CollectionViewSource.GetDefaultView(newValue);view.Filter+=this.FilterPredicate;'--------------------VB完整代码ProtectedOverloadsOverridesSubOnItemsSourceChanged(ByValoldValueAssystem.Collections.IEnumerable,ByValnewValueAsSystem.Collections.IEnumerable)IfnewValueIsNotNothingThenDimviewAsICollectionView=CollectionViewSource.GetDefaultView(newValue)view.Filter+=Me.FilterPredicate'这里出错EndIfIfoldValueIsNotNothingThenDimviewAsICollectionView=CollectionViewSource.GetDefaultView(oldValue)view.Filter-=Me.FilterPredicate'这里出错EndIfMyBase.OnItemsSourceChanged(oldValue,newValue)EndSubPrivateFunctionFilterPredicate(ByValvalueAsObject)AsBoolean'Wedon'tlikenulls.IfvalueIsNothingThenReturnFalseEndIf'Ifthereisnotext,there'snoreasontofilter.IfMe.Text.Length=0ThenReturnTrueEndIfDimprefixAsString=Me.Text'Iftheendofthetextisselected,donotmindit.IfMe.length>0AndAlsoMe.start+Me.length=Me.Text.LengthThenprefix=prefix.Substring(0,Me.start)EndIfReturnvalue.ToString().StartsWith(prefix,NotMe.IsCaseSensitive,CultureInfo.CurrentCulture)EndFunction
解决方案
解决方案二:
view.Filter=NewPredicate(OfObject)(AddressOfFilterPredicate)
解决方案三:
运行到view.Filter=NewPredicate(OfObject)(AddressOfFilterPredicate)不支持所指定的方法???
解决方案四:
view.Filter+=Me.FilterPredicate'这里出错AddHandlerView.filter,AddressOfMe.FilterPredicate
解决方案五:
运行到view.Filter=NewPredicate(OfObject)(AddressOfFilterPredicate)出错了,,,不支持所指定的方法???
解决方案六:
引用3楼xiaoxuanZhu的回复:
view.Filter+=Me.FilterPredicate'这里出错AddHandlerView.filter,AddressOfMe.FilterPredicate
这个试试看
解决方案七:
ToxiaoxuanZhu你的回答也不行出错,接口没这个事件view.Filter+=Me.FilterPredicate'这里出错AddHandlerView.filter,AddressOfMe.FilterPredicate
解决方案八:
学习下
解决方案九:
PartialPublicClassProductFormPublicSubNew()MyBase.New()Me.InitializeComponent()DimviewAsICollectionView=CollectionViewSource.GetDefaultView(ProductDetail.DataContext)'view.SortDescriptions.Add(NewSortDescription("PInstaller",ListSortDirection.Ascending))view.Filter=NewPredicate(OfObject)(AddressOfContains)'Insertcoderequiredonobjectcreationbelowthispoint.EndSubPublicFunctionContains(ByValdeAsObject)AsBooleanDimorder1AsProducts=TryCast(de,Products)Return(order1.PInstaller="JohnDoe")EndFunction一段网上代码
解决方案十:
UP