gpt4 book ai didi

listview - 在 WinJS 中更改 ListView 选择模板

转载 作者:行者123 更新时间:2023-12-02 19:17:19 24 4
gpt4 key购买 nike

我想更改 ListView 项目的默认选择模板。默认情况下,3 像素宽的灰色边框应用于当前选定的项目:

enter image description here

我在 ui.js 中发现,内部 _selectionTemplate 属性设置为默认边框:

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);

然而,由于 _selectionTemplate 是私有(private)的,因此修改 _selectionTemplate 属性本身似乎违反了 ListView 设计。是否有更好的解决方法来修改此默认选择模板?

最佳答案

覆盖默认模板使用的 CSS 类。例如,这会将边框更改为红色:

.win-listview .win-container:hover{
outline: rgba(255, 0, 0, 0.3) solid 3px;
}

关于listview - 在 WinJS 中更改 ListView 选择模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12106797/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com