自定义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>
上一篇: 获取多选下拉框(select标签设置multiple属性)的值
下一篇: 多选框