ItemsControl的ItemContainerStyle属性


ItemsControl:ListBox,ComboBox,TreeView

ItemContainerStyle是用来设置每一个集合控件的Item的样式的属性(即设置每一个项的样式)。 

  使用ItemContainerStyle 需要注意,如果集合控件的每一项是通过绑定生成的,则ItemContainerStyle对每一项Item都起作用,如果集合控件的项是通过直接在XAML中添加的,则ItemContainerStyle只对集合控件的第一层Item起作用。
  这个效果容易在TreeView等有层次结构的集合控件中引起误解。
 
 
例:
<Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="Control">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                    <Setter Property="Height" Value="42"/>
                </Style>
            </Setter.Value>
        </Setter>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM