2016-06-28 114 views
0

擴展WPF工具包包含一個PropertyGrid控件,該控件允許編輯對象屬性。 PropertyGrid具有的功能之一是搜索屬性名稱: enter image description here擴展WPF工具包 - PropertyGrid擴展搜索功能

當前,在搜索時,必須匹配屬性名稱的確切排序。例如,搜索「寵物」,返回正確的屬性。另一方面,搜索「名稱」不會返回任何結果。

有沒有辦法擴展搜索功能,所以它會啓用更靈活的搜索?

回答

1

好的找到了解決方案。

我不得不繼承PropertyGrid中,覆蓋OnFilterChanged方法,並更改過濾謂詞:

public class ExtendedPropertyGrid : PropertyGrid 
{ 
    protected override void OnFilterChanged(string oldValue, string newValue) 
    { 
     CollectionViewSource.GetDefaultView((object) this.Properties).Filter 
      = (item => (item as PropertyItem).DisplayName.ToLower().Contains(newValue.ToLower())); 
    } 
} 
0

V2.9有這個BUIT中,剛剛升級擴展WPF工具包