如何在ListView中更改项目的选择颜色?另外,我想更改项目周围边框的大小。默认情况下,选中该项目时的背景颜色为绿色,并且边框非常粗。
答案 0 :(得分:1)
您可以使用ItemContainerStyle更改选定的颜色和边框。 在设计器中右键单击您的ListView-> 编辑其他模板-> 编辑项目容器样式-> 编辑副本,则将生成默认的ItemContainerStyle。 ListViewItemPresenter中有一个 SelectedBackground 属性,您可以将其设置为所需的其他颜色,在这种情况下,所选颜色将发生变化。另外,如果要在选择项目时更改边框的大小,则存在一个表示选定状态的选定视觉状态,可以重置 RevealBorderThickness 和 RevealBorderBrush 在此状态下的属性。例如:
.xaml:
getoptionedExpansion(event)
{
if (event=="lvl1")
this.users.forEach(x=>x.hideThis=true)
if (event=="lvl2")
{
this.users.forEach(x=>x.hideThis=true)
this.users.forEach(x=>{
x.subItemsList.forEach(y=>{
y.hideThis=true
})
})
}
...you need make some similar with the others options and elements...
}