翻譯|使用教程|編輯:龔雪|2021-05-10 10:10:57.130|閱讀 260 次
概述:DevExpress WPF?擁有120+個(gè)控件和庫(kù),本文主要介紹如何為WPF數(shù)據(jù)網(wǎng)格控件創(chuàng)建自定義篩選器編輯器對(duì)話框。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
下載DevExpress v20.2完整版 DevExpress v20.2漢化資源獲取
DevExpress WPF Subscription擁有120+個(gè)控件和庫(kù),將幫助您交付滿足甚至超出企業(yè)需求的高性能業(yè)務(wù)應(yīng)用程序。通過(guò)DevExpress WPF能創(chuàng)建有著強(qiáng)大互動(dòng)功能的XAML基礎(chǔ)應(yīng)用程序,這些應(yīng)用程序?qū)W⒂诋?dāng)代客戶的需求和構(gòu)建未來(lái)新一代支持觸摸的解決方案。 無(wú)論是Office辦公軟件的衍伸產(chǎn)品,還是以數(shù)據(jù)為中心的商業(yè)智能產(chǎn)品,都能通過(guò)DevExpress WPF控件來(lái)實(shí)現(xiàn)。
從v19.1開(kāi)始,網(wǎng)格控件使用新的FilterEditorControl。UseLegacyFilterEditor設(shè)置為True,從而可以觸發(fā)FilterEditorCreated事件。 如果要自定義新的FilterEditorControl,是否還有另一個(gè)事件可以使用?
希望能夠創(chuàng)建由DxGrid控件使用的自定義FilterEditorControl對(duì)話框表單,使用更新的FilterEditorControl時(shí),如何完成利用網(wǎng)格引發(fā)的事件來(lái)攔截創(chuàng)建的舊版FilterControl并將其注入自定義形式?
要完成此任務(wù),可以使用TableView的屬性,該屬性將允許您重新定義FilterEditorContol的默認(rèn)對(duì)話框服務(wù)。 此代碼段演示了默認(rèn)實(shí)現(xiàn):
XAML
<dxg:TableView.FilterEditorDialogServiceTemplate> <DataTemplate xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" xmlns:dxfuit="http://schemas.devexpress.com/winfx/2008/xaml/core/filteringui/themekeys" xmlns:dxn="http://schemas.devexpress.com/winfx/2008/xaml/core/internal"> <ContentControl> <dx:DialogService DialogWindowStartupLocation="CenterOwner" ViewTemplate="{DynamicResource {dxfuit:FilterEditorThemeKey ResourceKey=FilterEditorDialogServiceViewTemplate}}"> <dx:DialogService.DialogStyle> <Style TargetType="{x:Type dx:ThemedWindow}"> <Setter Property="dxn:ThemedWindowOptions.ShowOverPopups" Value="True" /> <Setter Property="ShowInTaskbar" Value="False" /> <Setter Property="WindowStyle" Value="ToolWindow" /> <Setter Property="ShowIcon" Value="False" /> <Setter Property="UseLayoutRounding" Value="True" /> <Setter Property="Width" Value="500" /> <Setter Property="Height" Value="350" /> <Setter Property="MinWidth" Value="500" /> <Setter Property="MinHeight" Value="350" /> </Style> </dx:DialogService.DialogStyle> </dx:DialogService> </ContentControl> </DataTemplate> </dxg:TableView.FilterEditorDialogServiceTemplate>
要顯示自己的對(duì)話框按鈕,您將需要啟用ThemedWindowOptions.UseCustomDialogFooter屬性:
XAML
<dx:DialogService.DialogStyle> <Style TargetType="{x:Type dx:ThemedWindow}"> <Setter Property="dxn:ThemedWindowOptions.UseCustomDialogFooter" Value="True"/> <.../>
之后,您可以覆蓋FilterEditorTemplate屬性并定義自定義按鈕。
XAML
<dxg:TableView.FilterEditorTemplate> <DataTemplate xmlns:dxfui="http://schemas.devexpress.com/winfx/2008/xaml/core/filteringui"> <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <dxfui:FilterEditorControl x:Name="filterControl" /> <dx:ThemedWindowDialogButtonsControl Grid.Row="1"> <dx:ThemedWindowDialogButton Margin="6 0 0 0" Content="Cancel" DialogResult="Cancel" IsCancel="True" /> <dx:ThemedWindowDialogButton Margin="6 0 0 0" Content="Test" DialogResult="OK" Command="{DXCommand Execute='@e(filterControl).ApplyFilter()'}" IsDefault="True" /> </dx:ThemedWindowDialogButtonsControl> </Grid> </DataTemplate> </dxg:TableView.FilterEditorTemplate>
DevExpress技術(shù)交流群3:700924826 歡迎一起進(jìn)群討論
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都網(wǎng)