<Style TargetType="{x:Type ListBox}">
<!-- 定义ListBox自身外观, 比如: 圆角边框-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<Border CornerRadius="5" Background="pink">
<ScrollViewer HorizontalScrollBarVisibility="Hidden">
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ListBox Height="50" HorizontalAlignment="Left" Margin="236,84,0,0" Name="listBox1" VerticalAlignment="Top" Width="120" >
<ListBoxItem>wendyOne</ListBoxItem>
<ListBoxItem Foreground="White">wendyTwo</ListBoxItem>
<ListBoxItem>wendThree</ListBoxItem>
</ListBox>
wpf中有圆角的listbox
最新推荐文章于 2024-08-23 17:30:15 发布
本文介绍如何使用XAML自定义ListBox的样式,包括设置圆角边框、背景颜色及隐藏水平滚动条等。通过具体示例代码展示ListBox及其子项的外观定制过程。
353

被折叠的 条评论
为什么被折叠?



