-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.vb
More file actions
44 lines (39 loc) · 1.98 KB
/
MainWindow.xaml.vb
File metadata and controls
44 lines (39 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Imports DevExpress.Data.Filtering
Imports DevExpress.Xpf.Core.FilteringUI
Imports DevExpress.Xpf.Editors
Imports DevExpress.Xpf.Editors.Settings
Imports System
Imports System.Windows
Namespace WpfPivotCustomFilterDropDownExample
''' <summary>
''' Interaction logic for MainWindow.xaml
''' </summary>
Partial Public Class MainWindow
Inherits DevExpress.Xpf.Core.ThemedWindow
Public Sub New()
InitializeComponent()
End Sub
Private Sub ThemedWindow_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
pivotGridControl1.BestFitArea = DevExpress.Xpf.PivotGrid.FieldBestFitArea.FieldHeader
pivotGridControl1.BestFit()
End Sub
Private Sub OnExcelStyleFilterQueryOperators(ByVal sender As Object, ByVal e As ExcelStyleFilterElementQueryOperatorsEventArgs)
e.Operators.Clear()
e.Operators.Add(New ExcelStyleFilterElementOperatorItem(ExcelStyleFilterElementOperatorType.Between) With {.Caption = "Between"})
e.Operators.Add(New ExcelStyleFilterElementOperatorItem(ExcelStyleFilterElementOperatorType.DateOperators) With {.Caption = "Date Operators"})
e.Operators.Add(CreateLastYearsOperator())
End Sub
Private Function CreateLastYearsOperator() As ExcelStyleFilterElementOperatorItem
Const CustomFunctionName As String = "LastYears"
Dim currentYear = Date.Now.Year
Dim customFunction As ICustomFunctionOperatorBrowsable = CustomFunctionFactory.Create(CustomFunctionName, Function([date] As Date, threshold As Integer)
Return currentYear >= [date].Year AndAlso currentYear - [date].Year <= threshold
End Function)
CriteriaOperator.RegisterCustomFunction(customFunction)
Dim customFunctionEditSettings = New BaseEditSettings() {
New TextEditSettings With {.MaskType = MaskType.Numeric, .Mask = "D", .MaskUseAsDisplayFormat = True, .NullText ="Enter the number of years before..."}
}
Return New ExcelStyleFilterElementOperatorItem(CustomFunctionName, customFunctionEditSettings) With {.Caption = "Last Years"}
End Function
End Class
End Namespace