欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

自定义ListBox控件3

程序员文章站 2022-07-13 23:08:39
...
<ListBox ItemsSource="{Binding  ListTodo}"   BorderThickness="0"  Margin="25 0 0 0">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <UniformGrid  Columns="4"   >
                        </UniformGrid>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                        <!--<Setter Property="Cursor" Value="Hand"/>-->
                        <Setter Property="Margin" Value="0 20"/>
                        <Setter Property="HorizontalAlignment" Value="Left"/>
                        <Setter Property="VerticalAlignment" Value="Center"/>
                        <Setter Property="Background" Value="White"/>
                        <!-- 设置控件模板 -->
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem" >

                                    <StackPanel Orientation="Vertical">
                                        <TextBlock Text="{Binding Items}"/>
                                        <TextBlock Margin="0 10 0 0">
                                           <Run Text="{Binding TodeCount}" FontSize="16" FontFamily="Calibri" FontWeight="Black"/>
                                           <Run Text="{Binding Todedepict,StringFormat={}个{0}}" FontFamily="Calibri"/>
                                        </TextBlock>

                                    </StackPanel>
                                    <!--<ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="true">
                                            <Setter Property="Opacity"  Value="0.7"/>
                                        </Trigger>

                                    </ControlTemplate.Triggers>-->
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                        
                    </Style>
                </ListBox.ItemContainerStyle>

            </ListBox>

 

自定义ListBox控件3

 

 

相关标签: wpf样式效果