Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing ListView Selection Template in WinJS

I'd like to change the default selection template on ListView items. By default a 3 pixel wide gray border is applied to the currently selected item(s):

enter image description here

I did find in ui.js is that internally the _selectionTemplate property is set to the default border:

var selectionBorder = createNodeWithClass(WinJS.UI._selectionBorderContainerClass);
selectionBorder.appendChild(createNodeWithClass(WinJS.UI._selectionBorderClass + " " + WinJS.UI._selectionBorderTopClass));
selectionBorder.appendChild(createNodeWithClass(WinJS.UI._selectionBorderClass + " " + WinJS.UI._selectionBorderRightClass));
selectionBorder.appendChild(createNodeWithClass(WinJS.UI._selectionBorderClass + " " + WinJS.UI._selectionBorderBottomClass));
selectionBorder.appendChild(createNodeWithClass(WinJS.UI._selectionBorderClass + " " + WinJS.UI._selectionBorderLeftClass));

this._selectionTemplate = [];
this._selectionTemplate.push(createNodeWithClass(WinJS.UI._selectionBackgroundClass));
this._selectionTemplate.push(selectionBorder);
this._selectionTemplate.push(createNodeWithClass(WinJS.UI._selectionCheckmarkBackgroundClass));
var checkmark = createNodeWithClass(WinJS.UI._selectionCheckmarkClass);
checkmark.innerText = WinJS.UI._SELECTION_CHECKMARK;
this._selectionTemplate.push(checkmark);

However as _selectionTemplate is meant to be private it would seem to go against ListView design to modify the _selectionTemplate property itself. Is there a better workaround for modifying this default selection template?

like image 640
Gergely Orosz Avatar asked Feb 20 '23 09:02

Gergely Orosz


1 Answers

Override the CSS class used by the default template. For example this will change the border to red:

.win-listview .win-container:hover{
    outline: rgba(255, 0, 0, 0.3) solid 3px;
}
like image 84
Adam Kinney Avatar answered Mar 01 '23 23:03

Adam Kinney