首页 新闻 会员 周边 捐助

Silverlight listbox一行显示多个item

0
悬赏园豆:20 [已解决问题] 解决于 2010-06-23 14:32

Silverlight listbox一行显示多个item

 

ListBox 默认为一行显示一个Item

怎样设置 一行可显示多个,而且是可控的 (设置一行显示几个Itme)

 

请教高手

 

在线等待 谢谢

问题补充: 答案 <Grid.Resources> <Style TargetType="Separator"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Separator}"> <Border Width="2" Height="12" Margin="4" Background="Gray"/> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="ListBox"> <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center"/> </ItemsPanelTemplate> </Setter.Value> </Setter> </Style> </Grid.Resources> ... <ListBox Name="lb" Margin="10, 10, 3, 3" Height="50" Grid.Column="0" Grid.Row="2" Grid.RowSpan="2" SelectionChanged="PrintText"> <ListBoxItem>Item 1</ListBoxItem> <Separator/> <ListBoxItem>Item 2</ListBoxItem> <Separator/> <ListBoxItem>Item 3</ListBoxItem> <Separator/> <ListBoxItem>Item 4</ListBoxItem> <Separator/> <ListBoxItem>Item 5</ListBoxItem> <Separator/> <ListBoxItem>Item 6</ListBoxItem> <Separator/> <ListBoxItem>Item 7</ListBoxItem> <Separator/> <ListBoxItem>Item 8</ListBoxItem> <Separator/> <ListBoxItem>Item 9</ListBoxItem> <Separator/> <ListBoxItem>Item 10</ListBoxItem> </ListBox>
Peter.gao的主页 Peter.gao | 初学一级 | 园豆:65
提问于:2010-06-21 12:01
< >
分享
最佳答案
0

你的要求蛮新奇古怪的啊。类似这样的功能,不是非得要ListBox的吧?换个容器换个方式行不行?

一定要这样?改样式看看(比较笨欧):

代码
<ListBox Height="111" Margin="12,24,0,0" Name="listBox1" Width="134" HorizontalAlignment="Left" VerticalAlignment="Top" Opacity="1" SelectionChanged="listBox1_SelectionChanged">
<ListBoxItem Content="张三" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0" Height="18" Padding="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Name="lbxItem01" />
<ListBoxItem Content="李四" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="25,-18,0,0" Height="18" Padding="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Name="lbxItem02" />
<ListBoxItem Content="王五" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="50,-18,0,0" Height="18" Padding="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Name="lbxItem03" />
</ListBox>

另外,模板是咋回事,能行吗?要不你试试。我没玩过。

收获园豆:20
哈欠懒农 | 菜鸟二级 |园豆:455 | 2010-06-21 14:54
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册