-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.vb
62 lines (49 loc) · 2.06 KB
/
MainWindow.xaml.vb
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Imports DevExpress.Xpf.Grid
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Windows
Imports System.Windows.Controls
Namespace CustomGrouping_CodeBehind
Public Class Person
Public Property FirstName As String
Public Property LastName As String
Public Property UnitPrice As Integer
Public Sub New()
End Sub
Public Sub New(ByVal i As Integer)
FirstName = "FirstName" & i
LastName = "LastName" & i
UnitPrice = i
End Sub
End Class
Public Partial Class MainWindow
Inherits Window
Public Sub New()
Me.InitializeComponent()
Me.grid.ItemsSource = GetPersonList().ToList()
End Sub
Private Shared Function GetPersonList() As IEnumerable(Of Person)
Return Enumerable.Range(0, 100).[Select](Function(i) New Person(i))
End Function
Private Sub OnCustomColumnGroup(ByVal sender As Object, ByVal e As CustomColumnSortEventArgs)
If Not Equals(e.Column.FieldName, "UnitPrice") Then Return
Dim x As Double = Math.Floor(Convert.ToDouble(e.Value1) / 10)
Dim y As Double = Math.Floor(Convert.ToDouble(e.Value2) / 10)
e.Result = If(x > 9 AndAlso y > 9, 0, x.CompareTo(y))
e.Handled = True
End Sub
Private Sub OnCustomGroupDisplayText(ByVal sender As Object, ByVal e As CustomGroupDisplayTextEventArgs)
If Not Equals(e.Column.FieldName, "UnitPrice") Then Return
Dim interval As String = IntervalByValue(e.Value)
e.DisplayText = interval
End Sub
' Gets the interval which contains the specified value.
Private Function IntervalByValue(ByVal val As Object) As String
Dim d As Double = Math.Floor(Convert.ToDouble(val) / 10)
Dim ret As String = String.Format("{0:c} - {1:c} ", d * 10, (d + 1) * 10)
If d > 9 Then ret = String.Format(">= {0:c} ", 100)
Return ret
End Function
End Class
End Namespace