Files
docs-desktop/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/CollectionView.xaml.vb
T
Andy De George 9371b0126b Migrate .NET 3.1/5 WPF guide from dotnet docs (#48)
* add toc/bread changes

* add xaml-services

* add ported wpf content

* add xaml-services info to docfx

* Fix links 1

* Fix links 2

* Fix links 3

* Fix links 4

* Fix links 5

* Fix links 6

* Fix links 7

* Fix xaml-services link

* Fix snippets 1

* Fix snippets 2

* adjust breadcrumb and toc

* remove preserve-view from breadcrumbs

* add empty view to toc item xaml

* update include

* remove contextual toc for vs article :(
2020-09-17 08:41:01 -07:00

59 lines
2.0 KiB
VB.net

Imports System.ComponentModel
Public Class CollectionView
Public listingDataView As CollectionViewSource
Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs)
listingDataView = CType(Resources("listingDataView"), CollectionViewSource)
End Sub
' <ListingViewFilter>
Private Sub AddFilteringCheckBox_Checked(sender As Object, e As RoutedEventArgs)
Dim checkBox = DirectCast(sender, CheckBox)
If checkBox.IsChecked = True Then
AddHandler listingDataView.Filter, AddressOf ListingDataView_Filter
Else
RemoveHandler listingDataView.Filter, AddressOf ListingDataView_Filter
End If
End Sub
' </ListingViewFilter>
Private Sub AddGroupingCheckBox_Checked(sender As Object, e As RoutedEventArgs)
' <ListingGroupCheck>
' This groups the items in the view by the property "Category"
Dim groupDescription = New PropertyGroupDescription()
groupDescription.PropertyName = "Category"
listingDataView.GroupDescriptions.Add(groupDescription)
' </ListingGroupCheck>
End Sub
' <FilterEvent>
Private Sub ListingDataView_Filter(sender As Object, e As FilterEventArgs)
' Start with everything excluded
e.Accepted = False
Dim product As AuctionItem = TryCast(e.Item, AuctionItem)
If product IsNot Nothing Then
' Only include products with prices lower than 25
If product.CurrentPrice < 25 Then e.Accepted = True
End If
End Sub
' </FilterEvent>
' <AddSortChecked>
Private Sub AddSortCheckBox_Checked(sender As Object, e As RoutedEventArgs)
' Sort the items first by Category And then by StartDate
listingDataView.SortDescriptions.Add(New SortDescription("Category", ListSortDirection.Ascending))
listingDataView.SortDescriptions.Add(New SortDescription("StartDate", ListSortDirection.Ascending))
End Sub
' </AddSortChecked>
End Class