zoukankan      html  css  js  c++  java
  • 【WPF】修改ListBox的Item的样式

    <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>
  • 相关阅读:
    poj1088 经典dp
    poj2301
    poj1050(nyoj104 zoj1074)dp问题
    hdu1003
    poj1001(高精度)
    图的深度优先遍历DFS
    jquery中attr和prop的区别
    Apache 配置域名入口路径
    关于启动定时器和取消定时器的问题
    Web攻防之XSS,CSRF,SQL注入
  • 原文地址:https://www.cnblogs.com/mqxs/p/10942910.html
Copyright © 2011-2022 走看看