翻譯|使用教程|編輯:龔雪|2021-01-26 10:20:38.647|閱讀 246 次
概述:DevExpress WPF Subscription擁有120+個控件和庫,將幫助您交付滿足甚至超出企業(yè)需求的高性能業(yè)務(wù)應(yīng)用程序,本文將為大家介紹如何自定義RadioListFilterElement文本。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
下載DevExpress v20.2完整版 DevExpress v20.2漢化資源獲取
DevExpress WPF Subscription擁有120+個控件和庫,將幫助您交付滿足甚至超出企業(yè)需求的高性能業(yè)務(wù)應(yīng)用程序。通過DevExpress WPF能創(chuàng)建有著強大互動功能的XAML基礎(chǔ)應(yīng)用程序,這些應(yīng)用程序?qū)W⒂诋敶蛻舻男枨蠛蜆?gòu)建未來新一代支持觸摸的解決方案。 無論是Office辦公軟件的衍伸產(chǎn)品,還是以數(shù)據(jù)為中心的商業(yè)智能產(chǎn)品,都能通過DevExpress WPF控件來實現(xiàn)。
有一個用數(shù)據(jù)填充的GridControl和一個RadioListFilterElement,它引用網(wǎng)格為特定字段提供過濾器控件。 這可以正常工作,但是有一種情況需要RadioListFilterElement顯示與實際過濾的值不同的值。 例如,有問題的字段稱為StatusID,在數(shù)據(jù)庫中可能的值為:
但是在RadioListFilterElement中,想像這樣顯示它們:
可以在文本框或類似控件的上下文中通過簡單地使用轉(zhuǎn)換器來執(zhí)行此操作,但是在FilterElement的情況下,無法找到使其工作的方法。
當前過濾器元素:
XAML
<dxfui:RadioListFilterElement Context="{Binding FilteringContext, ElementName=UserListingGrid}" FieldName="StatusID" > </dxfui:RadioListFilterElement>
當前過濾器元素:
C#
class UserStatusIDConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if(value != null) { if(value.ToString() == "A") { return "ACTIVE"; } if (value.ToString() == "D") { return "DELETED"; } if (value.ToString() == "S") { return "SUSPENDED"; } } return false; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if(value == null) { return false; } if(value.ToString() == "ACTIVE") { return "A"; } else if(value.ToString() == "DELETED") { return "D"; } else if (value.ToString() == "SUSPENDED") { return "S"; } return false; } }
最簡單的方法是為過濾器元素創(chuàng)建自定義表示形式,可以使用FilterModelTemplate屬性來實現(xiàn)。 例如:
XAML
<dxfui:RadioListFilterElement Context="{Binding FilteringContext, ElementName=grid}" FieldName="Name"> <dxfui:RadioListFilterElement.FilterModelTemplate> <DataTemplate> <dxe:ListBoxEdit ItemsSource="{Binding FilterValues}" SelectedItem="{Binding SelectedFilterValue}" ShowCustomItems="True"> <dxe:ListBoxEdit.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Value, Converter={...}}" /> </DataTemplate> </dxe:ListBoxEdit.ItemTemplate> <dxe:ListBoxEdit.StyleSettings> <dxe:RadioListBoxEditStyleSettings /> </dxe:ListBoxEdit.StyleSettings> </dxe:ListBoxEdit> </DataTemplate> </dxfui:RadioListFilterElement.FilterModelTemplate> </dxfui:RadioListFilterElement>
DevExpress技術(shù)交流群3:700924826 歡迎一起進群討論
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都網(wǎng)