By default the Silverlight PivotViewer control does not support inversion of a facet category’s selections, even though internally the control has the functionality.
Some people have expressed a wish to improve the UX with a custom button to implement ‘invert selection‘.
This short post shows how to locate the UI elements for the facet manager and the view model in order to access this feature.
Locating the UI Elements
The flow of the code goes something like this:
- Locate the “PART_Container” in the tree. This is a Grid control.
- Locate the CollectionViewerView control.
- Locate the CollectionViewContainer control.
- Locate the CollectionViewerViewModel control.
Grid partContainer = (Grid)this.GetTemplateChild("PART_Container"); CollectionViewerView cvv = ((CollectionViewerView)(partContainer).Children); Grid container = cvv.Content as Grid; Grid viewerGrid = container.Children as Grid; CollectionViewContainer cvc = (CollectionViewContainer)viewerGrid.Children; CollectionViewerViewModel cvvm = (CollectionViewerViewModel)ViewBehaviors.GetViewModel(cvv);
The FacetManager contains a method to invert a facet category’s selection:
The easiest way of accessing this feature is with a custom button though no doubt a keyboard shortcut could be conjured up.
You will need some internal Microsoft Pivot references and usings too. Depending upon the extent of your other customizations you will need these:
Further things to do
This article is a brief guide to locating some visual elements of the Silverlight PivotViewer control in order to access the internal functionality that inverts the selections of a facet category. It targets the developer who has already started customizing the Silverlight PivotViewer control beyond the public API and alter the UX.
Any comments or request for future topics are welcome.