【WPF】修改ListBox的Item的样式
2024-08-28 05:14:21
<ListBox>
<!-- 数据 -->
<ListBoxItem>AAAA</ListBoxItem>
<ListBoxItem>BB</ListBoxItem>
<ListBoxItem>CCCC</ListBoxItem> <!-- 设置ListBoxItem样式 -->
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<!-- 设置控件模板 -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
TextBlock.Foreground="{TemplateBinding Foreground}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter> <!-- 设置触发器 -->
<Style.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="LightPink"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="LightGreen"/>
<Setter Property="Foreground" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
最新文章
- python学习笔记-python程序运行
- 【BZOJ】2563: 阿狸和桃子的游戏
- sencha动态向容器里添加控件出现重叠问题
- Struts2(二)---将页面表单中的数据提交给Action
- 笔记:PHP查询mysql数据后中文字符乱码
- python基础:三元运算
- Solr与Mysql简单集成
- DISCUZ! X2.5设置仅允许QQ登录注册论坛 加固会员注册机制
- 28个MongoDB NoSQL数据库的面试问答
- c# 哈希表集合;函数
- HTML5 canvas图像绘制方法与像素操作属性和方法
- qplot函数用法(转载)
- python之socket模块
- 【开源】 bsf.mvc spingboot的扩展
- 一个label两种颜色,一个label两种字体
- 开始一个django项目的流程
- PHP5.5+Nginx1.9
- libnids关于计算校验和引起的抓不到包的现象的解决方法
- 在 arc里面打印 引用计数的方法
- [LeetCode&;Python] Problem 561. Array Partition I
热门文章
- Linux Swap故障之 swapoff failed: Cannot allocate memory
- out文件 dev c++
- php怎么识别真实ip
- Ubuntu 18.04 环境下安装 Matlab2018
- nginx访问url内容过滤
- reflow和repaint理解总结
- day002-Linux基础之常用基本命令讲解
- haproxy 2.0 dataplaneapi rest api 几个方便的问题排查接口
- javascript冒泡排序 至少比较N(N-1)/2次;
- 全部文章>; Maven