首页 文章

拉伸水平ListBox

提问于
浏览
0

我想拉伸一个类似的列表框:

<Grid Background="#FFC0BBBB">
        <Grid.RowDefinitions>
            <RowDefinition Height="50" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Border HorizontalAlignment="Stretch" Grid.Row="0">
            <ListBox  Name="listBox"   >
                <ListBoxItem >
                    <StackPanel>
                        <TextBlock Text="Toto"></TextBlock>
                        <!--<Image Source ="" Visibility="Collapsed" />-->
                    </StackPanel>
                </ListBoxItem>
                <ListBoxItem >listbox item 2</ListBoxItem>
                <ListBoxItem >
                    <Grid>
                    <TextBlock Text="Tata"></TextBlock>
                    <Image Source ="" />
                    </Grid>
                </ListBoxItem>
                <ListBoxItem >
                    <Grid>
                        <TextBlock Background="Aqua" Text=""></TextBlock>
                        <Image Source ="https://support.twitter.com/images/twitter-bird.png?1339467554" />
                    </Grid>
                </ListBoxItem>
                <ListBoxItem >
                    <Grid>
                        <TextBlock Text="Vava"></TextBlock>
                        <Image Source ="" />
                    </Grid>
                </ListBoxItem>
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Columns="5" Background="Pink" HorizontalAlignment="Stretch" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>               
             </ListBox>
        </Border>
</Grid>

如果你只是为第二个项目添加内容它完美,但我的“真正的”ListBox将绑定,对于一些项目,我需要为其他人放一个图像TextBlock(我需要图像文本块) . 我认为我将不得不使用转换器,但我不知道“放在哪里”以及它应该返回什么 .

有任何想法吗 ?谢谢

1 回答

相关问题